Skip to content

Latest commit

 

History

History
67 lines (41 loc) · 3.35 KB

File metadata and controls

67 lines (41 loc) · 3.35 KB

Creational Design Patterns

Creational design patterns provide various object creation mechanisms, which increase flexibility and reuse of existing code.

Summary

Creational design patterns focus on object creation mechanisms, helping to make systems more flexible and reusable. These patterns abstract the instantiation process and help manage object creation complexity.

Overview of Creational Patterns

  1. Factory Method - Defers object creation to subclasses, allowing them to decide which class to instantiate
  2. Abstract Factory - Provides an interface for creating families of related objects without specifying their concrete classes
  3. Builder - Separates the construction of complex objects from their representation, allowing step-by-step construction
  4. Prototype - Creates new objects by cloning existing instances, useful when object creation is expensive
  5. Singleton - Ensures a class has only one instance and provides global access to it

One-shot : https://www.youtube.com/watch?v=OuNOyFg942M


1. Factory Method Pattern

Define an interface for creating an object, but let subclasses decide which class to instantiate.


2. Abstract Factory Pattern

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


3. Builder Pattern

Separate the construction of a complex object from its representation so that the same construction process can create different representations.


4. Prototype Pattern

Specify the kinds of objects to create using a prototypical instance, and create new objects by copying this prototype.


5. Singleton Pattern

Ensure a class has only one instance and provide a global point of access to it.