‎2014 May 03 2:08 PM
Hi Guys,
I have a question regarding the Design Pattern:Factory. According my need the question is below as:
Afterwards:
My question is:
How could I use the 20 methods of BBB without to declare them in AAA (without inheritance). Because, if I declare them in AAA, consequently they will be visible in CCC. And I don't want to ...
DATA BBB TYPE REF TO AAA. "Var Object BBB is type of Class AAA
DATA CCC TYPE REF TO AAA. "Var Object CCC is type of Class AAA
BBB = AAA=>Factory( 'BBB' ).
CCC = AAA=>Factory( 'CCC' ).
" I want to call, in that way:
BBB->method_bbb1().
CCC->method_ccc1().
CCC->method_bbb1(). " RAISE ERROR
I have found a way but I don't know if it's breaking the rules of the Factory Concept.
Have you got any idea?
Thank you in advance.
Rachid.
‎2014 May 05 9:38 AM
‎2014 May 05 10:31 AM
Hi,
If you have declared the methods in abstract class as protected or public and if you are inheriting it to the sub classes, then the methods will be available in the subclasses. There is no way to restrict like few abstract methods needs to be inherited and others need not be inherited. The inherited classes are forced to implement the abstract methods.
In your scenario, i do not think there is a need of abstract class, as I assume that both of your classes does some stand alone logic( as per your question ) compared to the other and doesn't have any common operations. Could you please let us know about this in detail ?? What about INTERFACES ?, Please have a look into it.
Kesav