A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Originally posted by Stan James:
I think that's what Cooper called Factory and GoF, um, apparently didn't think was worth mentioning.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Posted by Stan
I write an abstract class with an abstract method createNewWidget() that with an abstract Widget return type. If you want to extend that into a concrete class, you'll be required to implement createNewWidget and some concrete Widget. Some other extension of my abstract class might return a different concrete Widget. That's all there is to it.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by Ankit Doshi:
in Factory Method pattern, there is one abstract method (known as factory method) which takes care of the object creation, and may be this method is part of the client code (not sure about this though).
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by Ilja Preuss:
In the Factory Method pattern, the superclass is the client of a method that it defines as abstract, and which is implemented in subclasses.
Originally posted by Ankit Doshi:
In Factory pattern, there is a separate Factory class that takes care of object creation (based on some if else condition, or may be even using the property files as above)
Originally posted by Ankit Doshi:
Let's assume
- Product is the name of the class whose instances are needed
- ProductClient is the name of the client program which needs above instances
- getProduct() is the name of the abstract method which will be the factory method.
The question is - the getProduct() method will be part of which class? Part of ProductClient class? Or there's a seperate factory class like ProductFactory which contains the abstract getProduct() method?
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by Ilja Preuss:
If you have a ProductFactory class, you have a "creation class".
If the ProductFactory is abstract and the getProduct method implemented by different subclasses, you have an Abstract Factory.
If the getProduct method is declared abstract inside ProductClient, and implemented by its subclasses (without having a ProductFactory class at all), its a Factory Method.
Originally posted by Ilja Preuss:
If the ProductFactory is abstract and the getProduct method implemented by different subclasses, you have an Abstract Factory.
Originally posted by Peer Reynders:
I know I'm nitpicking...
but don't you need to create "a family of related product objects is designed to be used together" before your can call yourself an Abstract Factory (in the canonical form that is)?
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Montana has cold dark nights. Perfect for the heat from incandescent light. Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|