Design Patterns – Introduction
There are some scenarios which occur more frequently than others in designing java programs. The solutions of such problems can be done in several ways. But one of those solutions will be certainly best. Those best solutions have been figured out and termed as design patterns in java.
Whenever, a prgrammer encouters such a scenario or problem, he or she must apply appropriate design pattern to it. But before that, he or she should be able to understand which design pattern matches his/her problem. Let’s talk about these design patterns in detail.
Advantages of design patterns
- Design patterns are reusable programming solutions to specific kinds of problems
- Design patterns provide more clarity to applications designs
- They are proven solutions of certain problems, and thus there are very less chances of failures of them
- Design patterns make use of best programming practices.
- Use of design patterns make developers more solid understanding of an application
Types of design patterns
Primarily, design patterns have been categorized in following categories:
- Creational Design Pattern
- Structural Design Pattern
- Behavioral Design Pattern
1. Creational Design Pattern
Creational patterns talks about how objects should be created. In different use cases, we want objects to be created in different ways. This is where Creational Design Patterns come into picture.
Types of Creational Design Patterns
- Singleton Pattern
- Abstract Factory Pattern
- Factory Pattern
- Prototype Pattern
- Builder Pattern
- Object Pool Pattern
2. Structural Design Pattern
Structural patterns talks about how objects should be created to form a structure of objects using the concept of inheritance. These structures may enhance the functionalities of individual objects. In certain situations, such structures are formed to obtain some specific functionalities. Below are the types of structural design patterns
- Adapter Pattern
- Bridge Pattern
- Composite Pattern
- Decorator Pattern
- Facade Pattern
- Flyweight Pattern
- Proxy Pattern
3. Behavioral Design Pattern
Behavioral patterns talks about, as it name suggests, the behaviour and responsibilities of objects. It is concerned with the communication between objects.
- Command Pattern
- Chain of Responsibility Pattern
- Interpretar Pattern
- Iterator Pattern
- Memento Pattern
- Mediator Pattern
- Observer Pattern
- State Pattern
- Strategy Pattern
- Template Pattern
- Visitor Pattern
- Null Object Pattern