Wednesday, May 14, 2014

Abstract Factory Pattern in Java


Simple Note

(From wiki):
The abstract factory pattern provides a way to encapsulate a group of individual factories that have a common theme without specifying their concrete classes.
(From OODesign)
Offers the interface for creating a family of related object, without explicitly specifying their classes.

Program

https://github.com/benbai123/JSP_Servlet_Practice/tree/master/Practice/JAVA/DesignPattern/src/factory/abstractfactory

Run TestMain.java to test.

A FoodStore  that sells Bread from BreadFactory in odd weeks and sells PASTA from PastaFactory in even weeks.

In my opinion, Abstract Factory Pattern is most likely 'Chained Simple Factory Pattern'.

Reference:

Abstract factory pattern

Abstract Factory

No comments:

Post a Comment