Design Patterns
Design patterns are typical solutions to common problems in software design.
Table of Contents
Each pattern is like a blueprint that you can customize to solve a particular design problem in your code.
Creational Patterns
Factory Method
This creates a set of related objects or dependent objects.
- An abstract factory pattern acts as a super-factory that creates other factories.
An abstract factory interface is responsible for creating a set of related objects or dependent objects without specifying their concrete classes.
Basically, think in terms of abstracting the methods and properties of a UML diagram
Abstract Factory
interface Door { getDescription(): void; } class WoodenDoor implements Door { public function getDescription() { console.log("I am a wooden door"); } }
TODO Builder
TODO Prototype
Singleton
public Analytics { private static _instance: Analytics; private Analytics() { } public static getInstance(): Analytics { if (!Analytics._instance) Analytics._instance = new Analytics(); return Analytics._instance; } }