Re: abstract factory -- a doubt ?




daniel_t@xxxxxxxxxxxxx wrote:

Now that the set-up is done, I'll explain what I mean by "open up every
sub-class of the Factory and even the Abstract Factory itself."...
Suppose word from on high says our game now includes Artillery objects.
Now we also have Artillery, ArtilleryA, ArtilleryB, &c. This means the
Abstract Factory, and every sub-class of the factory needs a new method
"createArtillery"... Every sub-class of Factory needs to be modified,
as well as the AbstractFactory itself to accommodate this change. A
clear violation of the open-closed principle.

Are there ways to get around such a problem? Only if you use a
different creational pattern., however if you don't expect that such a
thing will happen, the AbstractFactory may be the best solution.

thanks. yes. it makes sense. guess it also corelates to the gang of
four book when they state that "supporting new kind of products is
difficult."

.



Relevant Pages

  • Re: using jMock with components
    ... >> chance to mock it. ... Whilst running normally the factory class returns ... > but don't worry about Abstract factory it is a valid approach. ... >> I created a factory interface which exposed the components I needed to ...
    (comp.lang.java.programmer)
  • Re: Difference between Factory and Abstract Factory
    ... abstract factory. ... these are like Abstract Factory and ... Factory Method respectively. ... Override methods like createThing() *in the factory*. ...
    (comp.object)
  • Re: using jMock with components
    ... Whilst running normally the factory class returns ... Usually its fine to have the createXXXComponent method on the abstract factory itself, which internally just delegates to the concrete factory. ... The reason I created the two factories is so I can omit the mock factory when I make a distribution. ... with the interface and merge the abstract and real factory classes together and create a getComponentmethod which creates a newInstance of the class using reflection, and have the test factory override that method. ...
    (comp.lang.java.programmer)
  • Re: Difference between Factory and Abstract Factory
    ... This is my take on the Abstract Factory. ... I was too lazy to create a concrete factory for every day of the week, ... public string GetDescription() ... class SaturdayMenu: IMenu ...
    (comp.object)
  • Re: abstract factory -- a doubt ?
    ... Factory does prevent violations of OCP. ... Abstract Factory... ... classes which use Tanks and APCs. ...
    (comp.object)