Following is diagram from "Manufacturing Java Objects with the Factory Method Design Pattern by Barry Burd and Michael P. Redlich" (http://javaboutique.internet.com/tutorials/factory/) explaining basic factory pattern.
Here, Creator is also user of the Product. This creation and use is tightly coupled.
A "SimpleProductFactory" element can be added to Creator class (composition), which would be responsible of creating Product. Thus, decoupling use and creation of the Product.
Links:-
* Sun Developer Forums: Problem understanding Factory Method Pattern
* Manufacturing Java Objects with the Factory Method Design Pattern by Barry Burd and Michael P. Redlich (http://javaboutique.internet.com/tutorials/factory/)
* Manufacturing Java Objects with the Factory Method Design Pattern by Barry Burd and Michael P. Redlich (http://javaboutique.internet.com/tutorials/factory/)


0 comments:
Post a Comment