Software Design Patterns - Abstract Factory

Abstract Factory

In this pattern, we use the concept of abstract and concrete. This pattern provides the interface to create objects (with similar nature but not same) without specifying the concrete object in advance.
The object creation task is insulated from the client as the clients request the factory object to create an object of the desired abstract type and to return an abstract pointer to the object.

To illustrate the concept graphically, I am including the images I borrowed from references.

The concept can be realized in the following UML diagram:

The example that we are discussing is illustrated in the following diagram:




The related source code is available at GitHub.

References

  1. Wikipedia
  2. sourcemaking.com
  3. tutorialspoint.com

No comments:

Post a Comment