Creational

Abstract Factory

Description

Provides an interface for creating families of related or dependent objects without specifying their concrete classes.

Where to use

  • Cross-platform UI toolkits.
  • \n
  • Theming systems.

Real World Example

A UI Factory creates Buttons and Checkboxes. The 'MacFactory' creates MacButton and MacCheckbox. The 'WinFactory' creates WinButton and WinCheckbox.

Code Example

class AbstractFactory:\n    def __init__(self):\n        pass\n\n    def execute(self):\n        print('Executing Abstract Factory')