Skip to content

curated collection of Java-based design patterns with clear explanations, real-world use cases, and clean implementations. Covers creational, structural, and behavioral patterns with a focus on clarity, modularity, and relevance to modern system design.

Notifications You must be signed in to change notification settings

Ashfaqbs/design-pattern

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Design patterns are reusable solutions to common software design problems. In Java, they are categorized broadly into three main types:

  1. Creational Design Patterns
    Focus: Object creation mechanisms to create objects in a way that is suitable for the situation.

    • Help make the system independent of how objects are created, composed, and represented.
    • Key idea: Control object creation to ensure flexibility and reuse.

    Examples:

    • Singleton
    • Factory Method
    • Abstract Factory
    • Builder
    • Prototype
  2. Structural Design Patterns
    Focus: Class and object composition to form larger structures.

    • Help ensure that different parts of a system work together in a flexible and efficient way.
    • Key idea: Simplify relationships between objects or combine them for new functionality.

    Examples:

    • Adapter
    • Bridge
    • Composite
    • Decorator
    • Facade
    • Flyweight
    • Proxy
  3. Behavioral Design Patterns
    Focus: Interaction and communication between objects.

    • Help define how objects interact, how responsibilities are distributed, and how workflows are controlled.
    • Key idea: Streamline complex communication between objects.

    Examples:

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

Quick Analogy for Understanding Types

  1. Creational Patterns: Think of building a house. You decide how to construct it: blueprint (Prototype), modular pieces (Builder), or hiring a factory (Factory Method).
  2. Structural Patterns: Consider how you connect rooms: walls (Adapter), open spaces (Bridge), or fancy decorations (Decorator).
  3. Behavioral Patterns: It’s about how people in the house interact: assigning tasks (Command), following workflows (Template Method), or broadcasting news (Observer).

About

curated collection of Java-based design patterns with clear explanations, real-world use cases, and clean implementations. Covers creational, structural, and behavioral patterns with a focus on clarity, modularity, and relevance to modern system design.

Topics

Resources

Stars

Watchers

Forks

Languages