Simple Note
Simple Factory Pattern:
A method that can return different hardcoded subtypes.
Program
https://github.com/benbai123/JSP_Servlet_Practice/tree/master/Practice/JAVA/DesignPattern/src/factory/simplefactory
BreadFactory that produce WonderfulBread at 3rd day of a week and produce CommonBread in other days
Can rely on the abstract class "Bread" in program, do not need to know whether it is a WonderfulBread or CommonBread
Reference:
Factory (object-oriented programming)
Simple Factory vs. Factory Method vs. Abstract Factory
No comments:
Post a Comment