A collection of design patterns implemented using TypeScript.
This repository provides an overview and implementation examples of various design patterns using TypeScript. Each design pattern has its own directory containing the code example, along with a brief explanation of the pattern, its purpose, and use cases.
Design patterns are reusable solutions to common software design problems. They provide a way to organize code and address common challenges in a structured and maintainable manner. Understanding and applying design patterns can improve code quality, extensibility, and readability.
This repository covers the following design patterns:
- Creational Design Patterns
- Singleton
- Factory Method
- Builder Pattern
- Structural Design Patterns
- Adapter Pattern (soon)
- Behavioral Design Patterns
To use the code examples, follow these steps:
Clone the repository:
git clone https://github.com/mmahareeq/Design-Patterns-TypeScript.git
Navigate to the cloned directory:
cd Design-Patterns-TypeScript
Each design pattern has its own directory, containing a separate JavaScript file and any necessary additional files. To run a specific example:
-
Navigate to the directory of the desired design pattern:
cd creational-patterns
-
install typescript
npm install -g typescript
-
compile a typescript file
tsc file-name.ts
-
run
node file-name.js