Design Patterns

Abstract Factory Pattern (GOF - Creational)

Abstract Factory pattern, takes object creation one step further from Factory Method pattern by making the application independent of how products are created, composed and represented.

One difference is that, with Abstract Factory pattern a class delegates the responsibility object instantiation to another object via composition where as Factoy Method pattern uses inheritance and relies on subclass to handle the desired object instantiation.

It suggests that high-level components should not depend on low-level components for object creation; rather, both should depend on abstraction. In other words, The Abstract factory provides an interface for creating families of related objects without specifying their concrete classes.

Abstract Factory characteristics

  1. Abstract Factory is an object maker.
  2. It typically produce more than one type of object.
  3. Each object that it creats, is known to the receiver of the created object only by that object's interface, not by the object's actual concrete implimentation.
  4. The different type of objects that abstract factory can produce are related - they are from a common family.
  5. Abstract Factory isolates concrete classes.



Class Diagram