Builder Pattern

The Builder pattern is a creational design pattern that separates the construction of complex objects from their representation. It provides a step-by-step approach to building objects, allowing you to create different variations of an object while keeping the construction process consistent. Example Here’s an example of the Builder pattern implemented in Python: class Product: def __init__(self): self.part_a = None self.part_b = None def __str__(self): return f"Part A: {self.part_a}, Part B: {self....

May 20, 2023 · aaron

Abstract Factory Pattern

The Abstract Factory pattern is a creational design pattern that provides an interface for creating families of related or dependent objects, without specifying their concrete classes. In this pattern, there is an abstract factory class that defines a set of abstract methods for creating related or dependent objects. Each concrete factory class that implements the abstract factory class provides its own implementation of these abstract methods, which creates specific families of related objects....

May 20, 2023 · aaron

Factory Method Pattern

“Define an interface for creating an object, but let subclasses decide which class to instantiate. The Factory method lets a class defer instantiation it uses to subclasses.” (Gang Of Four) The Factory Method design pattern is a creational design pattern that provides an interface for creating objects in a superclass, but allows subclasses to alter the type of objects that will be created. In other words, it encapsulates object creation and delegates it to subclasses, rather than instantiating objects directly in the superclass....

May 20, 2023 · aaron