Design Pattern

Basic Understanding

Factory Patternexample

Abstract Factory Patternexample

What is the basic difference between the Factory and Abstract Factory Patterns?

With the Factory pattern, you produce implementations (Apple, Banana, Cherry, etc.) of a particular interface — say, IFruit.
With the Abstract Factory pattern, you produce implementations of a particular Factory interface — e.g., IFruitFactory. Each of those knows how to create different kinds of fruit.

Factory pattern

Creational patterns abstract the object instantiation process. They hide how objects are created and help make the overall system independent of how its objects are created and composed.
Class creational patterns focus on the use of inheritance to decide the object to be instantiated Factory Method.
Object creational patterns focus on the delegation of the instantiation to another object Abstract Factory.

The Abstract Factory Pattern

Provide an interface for creating families of related or dependent objects without specifying their concrete classes.

The Abstract Factory pattern is very similar to the Factory Method pattern. One difference between the two is that with the Abstract Factory pattern, a class delegates the responsibility of object instantiation to another object via composition whereas the Factory Method pattern uses inheritance and relies on a subclass to handle the desired object instantiation. Actually, the delegated object frequently uses factory methods to perform the instantiation!




Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s