Skip to content

Latest commit

 

History

History
24 lines (14 loc) · 989 Bytes

abstract-factory.md

File metadata and controls

24 lines (14 loc) · 989 Bytes

Abstract Factory Pattern

Definition

Abstract Factory is a creational design pattern that lets you produce families of related objects without specifying their concrete classes.

Purpose

To create series of related or dependent objects without specifying their concrete classes. Usually the created classes all implement the same interface. The client of the abstract factory does not care about how these objects are created, it just knows how they go together.

For simple cases, this abstract class could be just an interface.

This pattern achieves the Dependency Inversion principle. It means the FactoryMethod class depends on abstractions, not concrete classes. This is the real trick compared to SimpleFactory or StaticFactory.

Example:

Furniture shop from where you can buy multiple items
Restaurant that can serve multiple items

Diagram Example

Code Example

(Example )