Re: Is a static method sufficient to call it factory?





f.vivoli@xxxxxxxxx wrote:
Well, actually the getInstance returns always the same instance of the
Factory class...

usually yes, but it doesn't have to. It can also return a subclass of Factory. If I understand correctly what you say



For subclassing I was meaning that the allocated objects do not
necessarily belong to the same class hierarchy of the factory.


It depends on what you mean by "allocated object". If you mean the result of createClass then no, it doesn't have to be a factory subclass. It shouldn't be. But you didn't give any information about the return type of getInstance (I assume it's Factory) and createClass.
So, supposing that getInstance returns a Factory, then createClass is your factory method. Now getInstance can return a subclass of Factory, and that subclass can implement its own crateClass method. This is the idea of the factory method.
.




Relevant Pages

  • Re: Is a static method sufficient to call it factory?
    ... > Harald wrote: ... you may want to hand the Factory object to ... > instance that is returned simply has a method createClass(), ... some interface implemented by my Factory. ...
    (comp.lang.java.programmer)
  • Re: Philosophical question on collection reference types
    ... Piotr Kobzda wrote: ... factory method like that: ... Here is a mistake in my treatment of second type parameter, not a generics implementation nor a compiler fault. ... it can be done correctly using factory object implementing the following-like interface: ...
    (comp.lang.java.programmer)
  • Re: Access subclass attributes from base
    ... factory object with the interface described earlier that implements more than ... The Instance property is the factory method that utilizes ... The subclasses only responsibility is to tell the base class to which ... super-generic base class contain it all. ...
    (microsoft.public.dotnet.framework.clr)
  • 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: The Factory Method
    ... On 10 May 2007, at 17:00, Robert Klemme wrote: ... a concrete factory - maybe even at the start of the article. ... So that would be the second factory method that all classes support. ...
    (comp.lang.ruby)