In the previous chapter, we have explained how Java Design Pattern helps software developers. This chapter explains about Java Design Pattern and its types.
There are three types of Java Design Patterns, they are:
Creational Design Pattern.
Structural Design Pattern.
Behavioral Design Pattern.
Creational pattern, Behavioral pattern and Structural pattern are sub divided into different patterns.
Conceptual
figure
Creational Pattern
Description
Creational Pattern deals with object creation and is mainly used to make a decision while creating an object for a class. Creational pattern controls the creation of object.
Creational Pattern is divided into 6 patterns:
Singleton Pattern.
Prototype Pattern.
Factory Method Pattern.
Abstract Factory Pattern.
Builder Pattern.
Object Pool Pattern.
Singleton Pattern
Singleton Pattern can increase the memory and efficiency of an object. Only one instance can be created for singleton pattern.
Prototype Pattern
Prototype Pattern is used for object cloning and can create a duplicate object.
Factory Method Pattern
Factory Method Pattern is used to create instances for derived classes.
Abstract Factory Pattern
Abstract Factory Pattern can create instances for family of classes.
Builder Pattern
Builder Pattern is used to separate the construction of an object from its representation.
Object Pool Pattern
Object Pool Pattern can enhance the performance of the system by recycling the unused objects.
Conceptual
figure
Behavioral Pattern
Description
Behavioral Pattern allows objects to interact in a much better way. The interactions must be loosely coupled so that they communicate with each other. Behavioral Pattern is divided into 12 patterns, they are:
Command Pattern.
Null Object.
Interpreter Pattern.
State Pattern.
Mediator Pattern.
Memento Pattern.
Observer Pattern.
Chain Of Responsibility Pattern.
Template Pattern.
Visitor Pattern.
Strategy Pattern.
Iterator Pattern.
Structural Pattern
Description
Structural patterns can be used to identify the relationship between various structures. Structural pattern focuses on how classes are inherited from one another. Structural Pattern is again divided into 7 patterns, they are:
Adapter Pattern.
Bridge Pattern.
Composite Pattern.
Decorative Pattern.
Flyweight Pattern.
Proxy Pattern.
Facade Pattern.
Summary
Key Points
Java Design Pattern are mostly used in Software Designing.
Design and analysis iterations can be reduced using Java Design Pattern.