This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
What is the difference between Factory pattern and Factory method pattern. Example: 1 A class has a method getObject( String type). This method returns one of the subclasses based on the type. Is this a Factory pattern or Factory method pattern. Example 2: A class has a method getObject(). A is an interface and b and c implement A. This method returns objects of the subclass(b). Is this a Factory pattern or Factory method pattern. I am not able to identify the patterns for the above examples. Please clarify.
I didn't know that there was two different patterns like that. Now there are two Factory patterns, but they are called Factory and Abstract Factory. One is concrete and the other is really a Factory interface, meaning the subclasses of this Factory implements which classes to return when the interface is implemented. In the regular Factory pattern, it already knows which type of classes it will return. You will us the Factory and not the Abstract Factory patterns. Example one to me looks like the Factory pattern, where Example two looks like it is trying to explain the Abstract Factory pattern. Mark
Thanks Mark. The following link discuss about the Factory Method Pattern.1. Factory Method Pattern According to this, does example 1 fall under factory method pattern. Please clarify. I am confused. 2. Factory method [ April 24, 2003: Message edited by: Saraswathy Krishnamoorth ] [ April 24, 2003: Message edited by: Saraswathy Krishnamoorth ]