A design pattern is a general reusable solution to a common problem that occurs in software design. It is a template that describes how to solve a particular problem that can be adapted to fit various situations.
Design patterns are usually created to address specific problems in software development and provide a standard solution that can be used across different programming languages and frameworks. They are not actual code but rather a conceptual framework or approach that helps developers organize and structure their code in a more efficient and scalable way.
Design patterns are classified into three main categories: creational patterns, structural patterns, and behavioral patterns. Creational patterns deal with the process of object creation, structural patterns deal with object composition and relationships, and behavioral patterns focus on how objects interact and communicate with each other.
Examples of popular design patterns include the Singleton pattern, Factory pattern, Adapter pattern, Observer pattern, and Decorator pattern. By using these patterns, developers can write more maintainable and reusable code that is easier to understand, modify, and extend over time.
In order to follow up with this repo, you would like to have a strong knowledge in:
- JavaScript and TypeScript
- Object Oriented Programming
- Software development in general
- Fork this repo
- Clone this repo:
git clone [your forked repo]
in a local environment - Initialize npm:
npm init -y
- Install all the necessary dependencies:
npm install
- Run the file you need with the command start. For example:
npm run start -- creational/factory/non-example.ts
The two hypens means that a param will be added next, which will be the path of the file you are gonna run
Along this repo, we are going to discover the most common design patterns, their use cases and examples written in TypeScript.
- Abstract Factory
- Builder
- Factory Method
- Prototype
- Singleton
- Adapter
- Bridge
- Composite
- Decorator
- Facade
- Flyweight
- Proxy
- Chain of responsability
- Iterator
- Memento
- State
- Template method
- Command
- Mediator
- Observer
- Strategy
- Visitor
This repo has been inspired in this article, with the purpose to add more example and use cases.