Abstract Factory – Provide an interface for creating families of related or dependent objects without specifying their concrete classes. [1]

Just wrote down a few notes.

First, abstract factory is for creating families of related or dependent objects. These objects are related or dependent upon each other so that they should be created together. They probably will be used / assembled together.

Second, one concrete implementation of abstract factory could be replaced by another concrete implementation, in theory.

Third, to make it easier for me to remember, I use this as the real-life example. Imagine I am a food supplier for fast food chains such as McDonald, Burger King, Wendy’s, etc. I would have an abstract factory to create abstract burgers, fries, drinks, cups, napkins, etc. I would also have a concrete factory to create concrete specialized products for McDonald, Burger King, Wendy’s each, respectively.

References:

  1. https://sourcemaking.com/design_patterns/abstract_factory
  2. https://www.tutorialspoint.com/design_pattern/abstract_factory_pattern.htm
  3. https://www.tutorialspoint.com/design_pattern/abstract_factory_pattern.htm
  4. https://en.wikipedia.org/wiki/Abstract_factory_pattern
  5. http://www.oodesign.com/abstract-factory-pattern.html
Advertisements