Skip to Content
0
Former Member
May 03, 2014 at 01:08 PM

[DESIGN PATTERN] Factory: Define Method Area

45 Views

Hi Guys,

I have a question regarding the Design Pattern:Factory. According my need the question is below as:


  1. I have the Abstract Class AAA with it own Abstract method that create objects (only one method).
  2. I have a Final Sub-Class BBB with 20 instantiate methods + the inherited method from Class AAA.
    1. BBB->method_bbb1().
    2. BBB->method_bbb2().
    3. BBB->method_bbb3().
  3. I have a Final Sub-Class CCC with 10 instantiate methods + the inherited method from Class AAA.
    1. CCC->method_ccc1().
    2. CCC->method_ccc2().
    3. CCC->method_ccc3().

Afterwards:

  1. Class BBB is instantiated through the Factory. The TYPE of BBB is AAA.
  2. Class CCC is instantiated through the Factory. The TYPE of CCC is AAA.

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.