Skip to content

Real-world design patterns in TypeScript with production use cases. Each pattern includes: problem it solves, when to use, trade-offs, and working examples.

Notifications You must be signed in to change notification settings

NandhakumarE/design-patterns-ts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Design Patterns in TypeScript

Welcome to the Design Patterns in TypeScript repository! 🎨 This collection showcases common design patterns in TypeScript, helping developers learn and build better, more scalable applications.

About This Repository

Design patterns are proven solutions to common software design problems. This repository covers a variety of patterns categorised into Creational, Structural, and Behavioural types, with real-world examples written in TypeScript.

Each pattern includes:

  • A concise explanation.
  • TypeScript implementation.
  • Use cases and benefits.

Patterns Included

1. Creational Patterns

  • Factory Pattern: Encapsulate object creation logic for better scalability.
  • Builder Pattern: Construct complex objects step-by-step.
  • Singleton Pattern: Ensure a class has only one instance.

2. Structural Patterns

  • Adapter Pattern: Bridge mismatched interfaces to ensure compatibility.
  • Decorator Pattern: Dynamically add behavior to objects.
  • Facade Pattern: Simplify complex subsystems with a unified interface.

3. Behavioural Patterns

  • Observer Pattern: Establish a publisher-subscriber relationship between objects.
  • Strategy Pattern: Define interchangeable algorithms for runtime flexibility.

Getting Started

Prerequisites

Installation

  1. Clone the repository:

     git clone https://github.com/NandhakumarE/design-patterns-ts.git
  2. Navigate to the project folder:

     cd design-patterns-ts
  3. Install dependencies:

     npm install

Run Examples

Every design pattern folder includes a test runner file to execute its implementation. To run an example:

  1. Use npx ts-node to execute the test file from the src directory:

     npx ts-node src/<pattern-folder>/<PatternTestFile>.ts

    Replace <pattern-folder> with the specific pattern folder (e.g., builder-pattern) and <PatternTestFile> with the test file name (e.g., BuilderPatternTest.ts).

    Example:

      npx ts-node src/builder-pattern/BuilderPatternTest.ts

Connect With Me

💼 LinkedIn - Nandhakumar Eswaran

About

Real-world design patterns in TypeScript with production use cases. Each pattern includes: problem it solves, when to use, trade-offs, and working examples.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published