A design pattern is used for solving the specific/common problem during the software development. This is just like a template for how to solve the common problem that can be used in many different situations. Using the design pattern application code will be more flexible, reusable and maintainable.
Advantages of Java design pattern:
- These are reusable.
- These are the defined solutions to general re occurring problems so it reduces time of application development.
- These are defined solution so any new or experience developer understands and debugs easily.
- These provide the best solutions that help to define the system architecture.
- These provide the communication between the developers.
- These provide clearness to the design of an application.
- These describe how the classes and objects interact in the application.
- These capture expert knowledge and make expertise widely available.
Here are mainly three types of design pattern.
Creational Design patterns: It is used to create an object instances in the best way because everyone know that object instance is created in Java using a new keyword but this is hard coding approach which is not good in the programming language
Student student = new Student ();
Using creational design patterns objects is created but hides the creation logic, rather than instantiating objects directly using new operator and this approach gives more flexibility in deciding which objects need to be created for a given use case.
Here are types of Creational Design patterns.
- Factory Pattern
- Abstract Factory Pattern
- Singleton Pattern
- Prototype Pattern
- Builder Pattern.
Structural Design patterns: Structural Patterns refers to the best design of instances and classes in a structured manner. It describes how objects can be associated and composed to form larger, more complex structures.
Here are types of Structural Design patterns:
- Adapter Pattern
- Bridge Pattern
- Composite Pattern
- Decorator Pattern
- Facade Pattern
- Flyweight Pattern
- Proxy Pattern
Behavioral Design patterns: Java Behavioral Patterns is concerned of interaction between java instances. You know in n-tire application loose coupling is the key area of application design. Behavioral Patterns is the industry`s best practice to design the communication channel between instances and their dependencies this means the implementation and the client should be loosely coupled in order to avoid hard coding and dependencies.
Here are types of Behavioral Design patterns:
- Chain Of Responsibility Pattern
- Command Pattern
- Interpreter Pattern
- Iterator Pattern
- Mediator Pattern
- Memento Pattern
- Observer Pattern
- State Pattern
- Strategy Pattern
- Template Pattern
- Visitor Pattern