Re: Is a static method sufficient to call it factory?
- From: Andrew McDonagh <news@xxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 28 Jul 2005 19:41:48 +0100
f.vivoli@xxxxxxxxx wrote:
Hi everyone,
I've just a doubt...
Talking about factories why someone propose the way
Factory.getInstance().createClass(aType);
instead of simply
Factory.createClass(aType);
That is, why the singleton?
In the end, is a class with a static method eligible to be an use of a factory method pattern? It doesn't resemble the structure of the GOF pattern, since it doesn't use subclassing...
Suppose that what createClass() method does is to instantiate a concrete class based on the parameter.
cheers, Francesco
You don't need an Abstract Factory to use a Singleton Pattern to get access to it, but the reason for doing so in the GoF Abstract Factory pattern, is so that we can *change* the factory that is actually returned and so we can call the createClass() method on any kind of factory.
For example, there could be some setup code that your app runs at startup, that decides which Concrete Factory to initialise the Abstract Factory with. Then the rest of the code base simply uses the AbstractFactory as you have seen, none the wiser that someone made a decision as to what the real concrete factory should be.
.
- References:
- Is a static method sufficient to call it factory?
- From: f . vivoli
- Is a static method sufficient to call it factory?
- Prev by Date: Re: Eclipse components
- Next by Date: Re: Runtime.exec() problem (jdk1.3.1+rh7, jdk1.4.2+rh9)
- Previous by thread: Re: Is a static method sufficient to call it factory?
- Next by thread: Re: Is a static method sufficient to call it factory?
- Index(es):
Relevant Pages
|
|