The design patterns are strategies for solving common object-oriented design problems. Using the design patterns you can make your code more flexible, reusable and maintainable. We must use the design patterns during the analysis and requirement phase of SDLC (Software Development Life Cycle).

A design pattern is a general reusable solution to a commonly occurring problem in software design. It is a description or template for how to solve a problem that can be used in many different situations. Object-oriented design patterns typically show relationships and interactions between classes or objects, without specifying the final application classes or objects that are involved.

Basically, design patterns are categorized into two parts:

  1. Core java (or JSE) Design Patterns.
  2. JEE Design Patterns.

At a higher level there are architectural patterns that are larger in scope, usually describing an overall pattern followed by an entire system.

There are many types of design patterns:

  1. Structural patterns address concerns related to the high level structure of an application being developed.
  2. Computational patterns address concerns related to the identification of key computations.
  3. Algorithm strategy patterns address concerns related to high level strategies that describe how to exploit application characteristic on a computation platform.
  4. Implementation strategy patterns address concerns related to the realization of the source code to support how the program itself is organized and the common data structures specific to parallel programming.
  5. Execution patterns address concerns related to the support of the execution of an application, including the strategies in executing streams of tasks and building blocks to support the synchronization between tasks.

Design patterns were originally grouped into the categories: creational patterns, structural patterns, and behavioral patterns.

Core Java Design Patterns

In core java, there are mainly three types of design patterns, which are further divided into their sub-parts:

1. Creational Design Pattern

Creational design patterns are concerned with the way of creating objects. These design patterns are used when a decision must be made at the time of instantiation of a class (i.e. creating an object of a class).

1. Factory Pattern

In Factory pattern, we create object without exposing the creation logic to the client and refer to newly created object using a common interface.

2. Abstract Factory Pattern

3. Singleton Pattern

4. Prototype Pattern

5. Builder Pattern.

2. Structural Design Pattern

Structural design patterns are concerned with how classes and objects can be composed, to form larger structures. The structural design patterns simplifies the structure by identifying the relationships. These patterns focus on, how the classes inherit from each other and how they are composed from other classes.

1. Adapter Pattern

2. Bridge Pattern

3. Composite Pattern

4. Decorator Pattern

5. Facade Pattern

6. Flyweight Pattern

7. Proxy Pattern

3. Behavioral Design Pattern

Behavioral design patterns are concerned with the interaction and responsibility of objects. In these design patterns, the interaction between the objects should be in such a way that they can easily talk to each other and still should be loosely coupled (A loosely coupled system is one in which each of its components has, or makes use of, little or no knowledge of the definitions of other separate components. Sub-areas include the coupling of classes, interfaces, data, and services.). That means the implementation and the client should be loosely coupled in order to avoid hard coding and dependencies.

1. Chain Of Responsibility Pattern

2. Command Pattern

3. Interpreter Pattern

4. Iterator Pattern

5. Mediator Pattern

6. Memento Pattern

7. Observer Pattern

8. State Pattern

9. Strategy Pattern

10. Template Pattern

11. Visitor Pattern

Another classification has also introduced the notion of architectural design pattern that may be applied at the architecture level of the software such as the Model-View-Controller pattern.

Enterprise Patterns

  1. Presentation Tier Patterns: Intercepting Filter, Front Controller, View Helper, Composite View, Service to Worker, Dispatcher View
  2. Business Tier Patterns: Business Delegate, Value Object, Session Facade, Composite Entity, Value Object Assembler, Value List Handler, Service Locator
  3. Integration Tier Patterns: Data Access Object, Service Activator

DTO is an abbreviation for Data Transfer Object, so it is used to transfer the data between classes and modules of your application. DTO should only contain private fields for your data, getters, setters and constructors. It is not recommended to add business logic methods to such classes, but it is OK to add some util methods.

DAO is an abbreviation for Data Access Object, so it should encapsulate the logic for retrieving, saving and updating data in your data storage (a database, a file-system, whatever).
Data Access Object Pattern or DAO pattern is used to separate low level data accessing API or operations from high level business services.

The MVC is a wider pattern. The DTO/DAO would be your model in the MVC pattern. It tells you how to organize the whole application, not just the part responsible for data retrieval.

The MVC (Model View Controller) design pattern is a pattern/architecture that can be used by GUI’s. It seperates the application’s data, user interface and control logic into three separate entities. This ensures the system will be more maintainable in the future as changes to one component will not have an affect on the others.

The MVC design pattern consists of three modules model, view and controller.

Model - The model represents the state (data) and business logic of the application.

View - The view module is responsible to display data i.e. it represents the presentation.

Controller - The controller module acts as an interface between view and model. It intercepts all the requests i.e. receives input and commands to Model / View to change accordingly.

Lazy loading is a design pattern commonly used in computer programming to defer initialization of an object until the point at which it is needed.

There are four common ways of implementing the lazy load design pattern: lazy initialization; a virtual proxy; a ghost, and a value holder.