Abstract Factory Patterns

  • This is a rarely used pattern. It exists only when you have factory patterns in the project.
  • Abstract factory expands on the basic factory pattern.
  • Abstract factory helps us to unite similar factory patterns classes into one unified interface. This leads to more simplified interface for the client.

65d74-dp8

Example:

Abstract Factory Patterns

 

Abstract Factory Patterns

 

Steps:

  • We have common an Interface or Abstract class

35bed-af1

  • The concrete classes implement this interface or abstract class.

43d7a-af2

  • Then a new factory class is created which takes care of object creation. A similar abstract factory class takes the decision of returning the asked factory object. This abstract class will be used by the client.

44e6e-af3

  • The client calls the static class object in above by creating an abstract class instead of the factory classes, as follows:

c38ee-af4

0 Comments

Leave a Comment