Various implementations of different design patterns.
This repository is my attempt to make sense of different design patterns, including tangible examples.
Every design pattern and code examples will be located into its own subfolder.
ℹ️ Make sure to have Node and NPM installed.
Inside a terminal run the following commands
npm install -g typescript
npm install -g ts-node
Inside a terminal, navigate to the folder with the code example and run the following command
ts-node index.ts
Creational | Structural | Behavioral |
---|---|---|
Abstract Factory | Adapter | Chain of Responsibility |
Builder | Bridge | Command |
Factory Method | Composite | Interpreter |
Prototype | Decorator | Iterator |
Singleton | Facade | Mediator |
Flyweight | Memento | |
Proxy | Observer | |
State | ||
Strategy | ||
Template | ||
Visitor |
Design principles are not patterns but can be used as mental reminders when designing software.
- Encapsulate what varies.
- Favor composition over inheritance.
- Program to interfaces, not implementations.
- Strive for loosely coupled designs between objects that interact.
- Classes should be open for extension but closed for modification.
- Depend upon abstractions. Do not depend upon concrete classes.
- The Least amount of Knowledge; Only talk to your immediate friends.
- Don’t call us, we’ll call you.
- A class should have only one reason to change.