Design Patterns

Design Patterns

All 23 Gang of Four patterns โ€” Creational, Structural, and Behavioral โ€” with multi-class UML diagrams, full Java implementations, anti-patterns, and interview preparation guides.

23 patterns 3 categories 4 reference guides Java + Python implementations
01
Category One ยท Object Creation

Creational Patterns

๐Ÿ“ฆ

Singleton

  • Ensure a class has only one instance
  • Tier 1 ยท Foundational
๐Ÿญ

Factory Method

  • Defer instantiation to subclasses
  • Tier 1 ยท Foundational
๐Ÿ—๏ธ

Abstract Factory

  • Create families of related objects
  • Tier 2 ยท Intermediate
๐Ÿงฑ

Builder

  • Construct complex objects step by step
  • Tier 2 ยท Intermediate
๐Ÿ‘

Prototype

  • Clone existing objects without coupling
  • Tier 3 ยท Intermediate
02
Category Two ยท Object Composition

Structural Patterns

๐Ÿ”Œ

Adapter

  • Convert one interface to another
  • Tier 2 ยท Foundational
๐ŸŒ‰

Bridge

  • Separate abstraction from implementation
  • Tier 3 ยท Intermediate
๐ŸŒฒ

Composite

  • Compose objects into tree structures
  • Tier 2 ยท Intermediate
๐ŸŽ

Decorator

  • Add responsibilities dynamically
  • Tier 1 ยท Intermediate
๐Ÿ 

Facade

  • Provide a simplified interface
  • Tier 2 ยท Foundational
๐Ÿชถ

Flyweight

  • Share fine-grained objects efficiently
  • Tier 3 ยท Advanced
๐Ÿ›ก๏ธ

Proxy

  • Control access to another object
  • Tier 2 ยท Intermediate
03
Category Three ยท Communication

Behavioral Patterns

๐Ÿ””

Observer

  • Notify dependents of state changes
  • Tier 1 ยท Foundational
โ™Ÿ๏ธ

Strategy

  • Encapsulate interchangeable algorithms
  • Tier 1 ยท Foundational
๐Ÿ“œ

Command

  • Encapsulate a request as an object
  • Tier 2 ยท Intermediate
๐Ÿ“‹

Template Method

  • Define algorithm skeleton, defer steps
  • Tier 2 ยท Foundational
โ›“๏ธ

Chain of Responsibility

  • Pass request along a chain of handlers
  • Tier 3 ยท Intermediate
๐Ÿšฆ

State

  • Alter behavior when internal state changes
  • Tier 2 ยท Intermediate
๐Ÿ“ก

Mediator

  • Centralize complex communications
  • Tier 3 ยท Intermediate
๐Ÿ”

Iterator

  • Access elements sequentially
  • Tier 2 ยท Foundational
๐Ÿง‘โ€๐Ÿ’ผ

Visitor

  • Add operations without changing classes
  • Tier 3 ยท Advanced
๐Ÿ“ธ

Memento

  • Capture and restore object state
  • Tier 3 ยท Intermediate
๐Ÿ”ค

Interpreter

  • Define a grammar and interpret sentences
  • Tier 3 ยท Advanced
04
Category Four ยท Reference Guides

Reference & Guides

๐ŸŽฏ

Interview Patterns

  • Tier 1โ€“3 pattern ranking
  • What interviewers test
โš ๏ธ

Anti-Patterns

  • The wrong approach for each pattern
  • How to recognise and fix them
๐Ÿ”—

Pattern Relationships

  • Confused-with pairs
  • Compose-together trios
โ˜•

Java Stdlib Map

  • Every pattern in the JDK
  • Real class and method references