Abstract Factory Pattern

Abstract Factory Pattern provides an interface for creating a factory of related objects without explicitly specifying their classes. In other words, the Abstract Factory is a super-factory which creates other factories (Factory of factories).

Implementation
Abstract Factory Pattern
In the above URL class diagram,
AbstractFactory defines a Factory Method per product:
ConcreteFactoryA and ConcreteFactoryB implement methods to create concrete product A and B
AbstractProductA declares the interface of product A
AbstractProductB declares the interface of product B

Example code:

Output:
FactoryAProduct1 created
FactoryBProduct2 created

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInShare on RedditShare on StumbleUponEmail this to someoneShare on TumblrDigg this

One thought on “Abstract Factory Pattern

  1. Pingback: Software Design Patterns

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">