Common GoF Design Pattern overview
The authors Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides are often referred to as the GoF, or Gang of Four. They published a book titled Design Patterns: Elements of Reusable Object-Oriented Software, which initiated the concept of design patterns in software development.
In this chapter, you will learn what GOF patterns are and how they help solve common problems encountered in object-oriented design.
The Gang of Four (GoF) patterns are 23 classic software design patterns providing recurring solutions to common problems in software design. The patterns are defined in the book Design Patterns: Elements of Reusable Object-Oriented Software. These patterns are categorized into two main categories:
- Core Design Patterns
- J2EE Design Patterns
Furthermore, Core Design Patterns are also subdivided into three main categories of design pattern, as follows:
- Creational Design Pattern: Patterns under this category provide a way to construct objects when constructors will not serve your purpose. The creation logic of objects is hidden. The programs based on these patterns are more flexible in deciding object creation according to your demands and your use cases for the application.
- Structural Design Pattern: Patterns under this category deal with the composition of classes or objects. In the enterprise application, there are two commonly used techniques for reusing functionality in object-oriented systems: one is class Inheritance and the other is the Object Composition Concept of inheritance. The Object Composition Concept of inheritance is used to compose interfaces and define ways to compose objects to obtain new functionalities.
- Behavioral Design Pattern: Patterns under this category, characterize the ways in which classes or objects interact and distribute responsibility. These design patterns are specifically concerned with communication between objects. The behavioral design pattern is used to control and reduce complicated application flow in the enterprise application.
Now, let's look at the other category, the JEE Design patterns. This is the other main category of design patterns. Application design can be immensely simplified by applying Java EE design patterns. Java EE design patterns have been documented in Sun's Java Blueprints. These Java EE Design patterns provide time-tested solution guidelines and best practices for object interaction in the different layers of a Java EE application. These design patterns are specifically concerned with the following listed layers:
- Design pattern at the presentation layer
- Design pattern at the business layer
- Design pattern at the integration layer
Let's explore creational design patterns in the upcoming section.