2015-06-05

Design patterns have evolved to solve problems often encountered in software applications. The factory method design pattern and the abstract factory design pattern are both creational patterns. Creational patterns are used to abstract object creation and hide the intricacies of how the objects are actually created. In this post, I will present a discussion on the factory method and abstract factory design patterns and their applicability.

Simple factory, factory method, and abstract factory design patterns

A simple factory is one that returns an instance of many different classes. Note that these classes may have the same base class or these may implement a common interface. While a simple factory can be called by the client using a static method and returns instances of classes that have the common base or parent, the factory method encapsulates the object creation logic inside the sub classes. The abstract factory design is used to a set of related instances without specifying the concrete classes -- it uses the factory method design pattern to create instances of classes.

To read this article in full or to leave a comment, please click here

Show more