Re: Is a static method sufficient to call it factory?
- From: Thomas Weidenfeller <nobody@xxxxxxxxxxxxxxxx>
- Date: Thu, 28 Jul 2005 16:21:18 +0200
f.vivoli@xxxxxxxxx wrote:
Talking about factories why someone propose the way
Factory.getInstance().createClass(aType);
instead of simply
Factory.createClass(aType);
That is, why the singleton?
Without knowing the inner details of the involved methods it is difficult to say, but very often a singleton is just used to hide a static method or a global variable, so the code looks more object-oriented. It is maybe the most common abuse of the singleton design pattern.
Should this be the case then I would suggest to drop the singleton. Why do you want to fool yourself with a singleton, if you don't need any of its features?
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...
Do you want to write more code just to follow a book, or do you want to have simpler (so less error prone) code? If a GoF pattern doesn't fit, it doesn't fit, so why spend extra effort to make it fit?
/Thomas -- The comp.lang.java.gui FAQ: ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/ .
- 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: URI
- 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
|
|