Skip to content

Latest commit

 

History

History
51 lines (43 loc) · 1.97 KB

File metadata and controls

51 lines (43 loc) · 1.97 KB

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).