Design Patterns

  • A design pattern is a well-described solution to a common software problem.

  • They are like pre-made blueprints that you can customize to solve a recurring design problem in your code.

  • The pattern is not a specific piece of code, but a general concept for solving a particular problem.

  • Some of the benefits of using design patterns are:

    • Design patterns are already defined and provide an industry-standard approach to solving a recurring problem, so it saves time if we sensibly use the design pattern.
    • Using design patterns promotes re-usability that leads to more robust and highly maintainable code. It helps in reducing the total cost of ownership (TCO) of the software product.
    • Since design patterns are already defined, it makes our code easy to understand and debug. It leads to faster development and new members of the team understand it easily.
  • Java design patterns are divided into three categories: creational, structural, and behavioral design patterns.

Creational Design Patterns

  • Creational design patterns provide solutions to instantiate an Object in the best possible way for specific situations.

    Patterns
    1 Singleton Pattern
    2 Factory Pattern
    3 Abstract Factory Pattern
    4 Builder Pattern
    5 Prototype Pattern

Structural Design Patterns

  • Structural design patterns provide different ways to create a Class structure (for example, using inheritance and composition to create a large Object from small Objects).

  • Structural patterns explain how to assemble objects and classes into larger structures, while keeping these structures flexible and efficient.

    Patterns
    1 Adapter Pattern
    2 Composite Pattern
    3 Proxy Pattern
    4 Flyweight Pattern
    5 Facade Pattern
    6 Bridge Pattern
    7 Decorator Pattern

Behavioral Design Patterns

  • Behavioral patterns provide a solution for better interaction between objects and how to provide loose-coupling and flexibility to extend easily.

  • Behavioral patterns take care of effective communication and the assignment of responsibilities between objects.

    Patterns
    1 Template Method Pattern
    2 Mediator Pattern
    3 Chain of Responsibility Pattern
    4 Observer Pattern
    5 Strategy Pattern
    6 Command Pattern
    7 State Pattern
    8 Visitor Pattern
    9 Interpreter Pattern
    10 Iterator Pattern
    11 Memento Pattern

Miscellaneous Design Patterns

Patterns
1 DAO Design Pattern
2 Dependency Injection Pattern
3 MVC Pattern