A design pattern is a tried and tested solution to a common software. The famous “Gang Of Four”, or GoF as they came to be known, saw reoccuring problems in their experience as developers, and documented solutions in their in their classic book “Design Patterns: Elements of Reusable Object-Oriented Software”.
Here we will look further into design patterns. We will aim to understand the problem each pattern solves, and an example of how to implement the solution in Java.
Benefits Of Using Design Patterns in Java
The key benefits of using design patterns are:
- Describe a standard approach thats more easily understood to solve a commonly occurring problem.
- Save development time by implementing that industry standard approach.
- Helps with maintenance and reuse of code, as common solution is easier to work with and understand
Types Of Design Patterns
The “Gang Of Four” defined 3 different types of design patterns.
- Creational patterns deal with class instantiation or object creation, and using those to control how objects get created.
- Structural patterns organise classes and objects to provide new functionality, based on their composition.
- Behavioral patterns concern themselves with interactions betweeen objects by implementing common communication patterns.