Skip to content

kumaratul60/design-patterns

Repository files navigation

Design Patterns

A curated collection of JavaScript and React design patterns with clear explanations and practical implementations.

Each pattern includes: Problem → When to Use → Trade-offs → JS / React Example


Contents

Pattern Mapping

  • Creational → object creation, factories, configuration
  • Structural → composition, API boundaries, reuse
  • Behavioral → state, events, async flows
  • React Patterns → component architecture, state ownership, performance

Fundamental creational, structural, and behavioral patterns implemented in pure JavaScript.

Creational Patterns

Structural Patterns

Behavioral Patterns


React-specific patterns for scalable, maintainable UI architecture.

React patterns focus on composition and state management, not classical GoF OO class hierarchies.


GoF (Gang of Four) Context

What “Object-Oriented” Means

  • Class-based design
  • Inheritance + polymorphism
  • Encapsulation via objects
  • Originally designed for C++ / Java-style OOP

The 3 GoF Categories (Classic)

Creational

  • Singleton
  • Factory / Abstract Factory
  • Builder
  • Prototype

Structural

  • Adapter
  • Decorator
  • Facade
  • Proxy
  • Flyweight
  • Bridge
  • Composite

Behavioral

  • Strategy
  • Observer
  • State
  • Command
  • Iterator
  • Mediator
  • Chain of Responsibility
  • Template Method
  • Visitor
  • Memento
  • Interpreter

Important Interview Clarity (JS / React)

  • GoF patterns ≠ React patterns
  • React favors functions + composition, not inheritance
  • GoF ideas still apply, but are expressed functionally

Concept Mapping

  • Strategy → function maps / hook selectors
  • Observer → events, RxJS, React state updates
  • Decorator → HOCs / function composition
  • Factory → config-based object or hook creation

React Pattern Categories

Structural / Composition

Behavioral / State

Reusability

Performance


WEB-Design

Getting Started

  • Start with Design-Patterns/ for core concepts
  • Move to React-Design-Patterns/ for real-world UI architecture

Contributing

Contributions are welcome! Open a pull request or raise an issue here.

About

Write clean, scalable JavaScript and React by learning the design patterns that actually matter from core creational, structural, and behavioral patterns to modern React component architecture, with real-world examples and best practices.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors