Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Originally posted by Tulsi Rai:
is this example for Abstract Factory or Factory Method?
Originally posted by Tulsi Rai:
Also, what good the decouple does?
Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
"Write beautiful code; then profile that beautiful code and make little bits of it uglier but faster." --The JavaPerformanceTuning.com team, Newsletter 039.
Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
42
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:
As far as I can tell, "Factory" is just a short hand for the original "Abstract Factory" pattern.
Originally posted by Frank Silbermann:
No, the Gang of Four book lists them as two separate patterns.
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:
As far as I can tell, "Factory" is just a short hand for the original "Abstract Factory" pattern.
Originally posted by Ilja Preuss:
I am quite sure that there is no "Factory" pattern in the GoF book. Perhaps you are confusing it with "Factory Method"?
Originally posted by Frank Silbermann:
I always assumed "Factory" was short hand for the original "Factory Method" pattern.
"Factory Method" is no less abstract than "Abstract Factory" -- and "Abstract Factory" is no less methodical than "Factory 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
42
Originally posted by Jeroen Wenting:
Looking it up in Grand (Patterns In Java Volume 1 page 99) gives:
"Given a set of related abstract classes, the Abstract Factory pattern provides a way to create instances of those abstract classes from a matches set of concrete subclasses".
Factory pattern:
"You organise this class so that it can instantiate other classes without being dependent on any of the classes it instantiates".
So an abstract factory is a factory that creates instances of concrete classes derived from abstract classes while a factory creates instances of concrete classes which aren't necessarilly based on anything???
The Factory Method provides a simple decision making class which returns one of several possible subclasses of an abstract base class depending on data it is provided. (emphasis added)
The Abstract Factory Method provides an interface to create and return one of several families of related objects.
Johnny Hunter
SCJP 1.4
Originally posted by Frank Silbermann:
--------------------------------------------------------------------------------
The Factory Method provides a simple decision making class which returns one of several possible subclasses of an abstract base class depending on data it is provided. (emphasis added)
The Abstract Factory Method provides an interface to create and return one of several families of related objects.
--------------------------------------------------------------------------------
Notice that the word abstract is used in the Factory Method definition -- but not in the Abstract Factory definition![/QB]
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
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |