Skip to content

Mattee37/design-patterns

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Design Patterns in TypeScript

A comprehensive collection of the 23 Gang of Four (GoF) design patterns implemented in TypeScript with Bun.

Reference

These patterns are based on the classic book:

"Design Patterns: Elements of Reusable Object-Oriented Software"
by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides
Addison-Wesley, 1994

Also known as the "Gang of Four" (GoF) book, it remains the definitive reference for object-oriented design patterns.

Overview

mindmap
  root((Design Patterns))
    Creational
      Factory
      Abstract Factory
      Builder
      Prototype
      Singleton
    Structural
      Adapter
      Bridge
      Composite
      Decorator
      Facade
      Flyweight
      Proxy
    Behavioral
      Chain of Responsibility
      Command
      Interpreter
      Iterator
      Mediator
      Memento
      Observer
      State
      Strategy
      Template Method
      Visitor
Loading

Patterns

Creational Patterns

Deal with object creation mechanisms.

Pattern Description Run
Factory Create objects without specifying exact class bun run creational:factory
Abstract Factory Create families of related objects bun run creational:abstract-factory
Builder Construct complex objects step by step bun run creational:builder
Prototype Clone existing objects bun run creational:prototype
Singleton Ensure single instance bun run creational:singleton

Structural Patterns

Deal with object composition.

Pattern Description Run
Adapter Convert interface to expected one bun run structural:adapter
Bridge Separate abstraction from implementation bun run structural:bridge
Composite Treat objects and groups uniformly bun run structural:composite
Decorator Add behavior dynamically bun run structural:decorator
Facade Simplify complex subsystems bun run structural:facade
Flyweight Share common state efficiently bun run structural:flyweight
Proxy Control access to objects bun run structural:proxy

Behavioral Patterns

Deal with object communication.

Pattern Description Run
Chain of Responsibility Pass request along handler chain bun run behavioral:chain-of-responsibility
Command Encapsulate requests as objects bun run behavioral:command
Interpreter Evaluate language grammar bun run behavioral:interpreter
Iterator Access elements sequentially bun run behavioral:iterator
Mediator Centralize complex communications bun run behavioral:mediator
Memento Capture and restore state bun run behavioral:memento
Observer Notify dependents of changes bun run behavioral:observer
State Alter behavior based on state bun run behavioral:state
Strategy Interchange algorithms bun run behavioral:strategy
Template Method Define algorithm skeleton bun run behavioral:template-method
Visitor Add operations without modifying classes bun run behavioral:visitor

Getting Started

# Install dependencies
bun install

# Run any pattern
bun run <category>:<pattern>

# Example
bun run creational:factory

Project Structure

src/
├── creational/
│   ├── factory/
│   ├── abstract-factory/
│   ├── builder/
│   ├── prototype/
│   └── singleton/
├── structural/
│   ├── adapter/
│   ├── bridge/
│   ├── composite/
│   ├── decorator/
│   ├── facade/
│   ├── flyweight/
│   └── proxy/
└── behavioral/
    ├── chain-of-responsibility/
    ├── command/
    ├── interpreter/
    ├── iterator/
    ├── mediator/
    ├── memento/
    ├── observer/
    ├── state/
    ├── strategy/
    ├── template-method/
    └── visitor/

Requirements

  • Bun v1.0+
  • TypeScript 5+

About

A comprehensive collection of the 23 Gang of Four (GoF) design patterns implemented in TypeScript with Bun.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors