This repository contains practical examples of common design patterns implemented in TypeScript. Each example is designed to be simple, understandable, and relevant to real-world web development scenarios.
- Clone the repository
- Install dependencies
npm install
- Run any pattern example using the npm scripts
npm run design-pattern:<pattern-name>
Demonstrates object creation through a notification system, showing how to create different types of notifications (email, SMS, push) using a common interface.
npm run design-pattern:factory
Shows how to ensure a single instance of a database connection is shared across the application.
npm run design-pattern:singleton
Illustrates how to make incompatible interfaces work together using payment provider integration as an example.
npm run design-pattern:adapter
Demonstrates how to add new behaviors to objects dynamically using logging and performance measurement examples.
npm run design-pattern:decorator
Shows how to abstract data access logic using a simple user management system.
npm run design-pattern:repository
Shows how objects can notify other objects of state changes using a weather station example with multiple displays.
npm run design-pattern:observer