What are design patterns? A design pattern is a re-usable form of a solution to a design problem. They come about from experiencing similar design problems repeatedly and discovering a novel way to solve for them, the design pattern. Hence design problems are not discovered, but rather forged through the act of solving design problems.
Why learn them?
Design patterns provide many benefits that we can take advantage of.
Don’t reinvent the wheel
We often run into similar problems that we have solved previously, our colleagues have seen before, and that others around the world have
By knowing and naming design patterns we can more easily communicate with other software professionals. Rather than having to explain the entire concept, we can simply identify the pattern by its name and we will have communicated our intent much more simply.
Patterns can be organized into three main groups based on how they are used. The groups are creational, structural and behavioral.
Creational design patterns help abstract the instantiation process.
Structural patterns help with how classes and objects are composed to form larger structures.
Behavioral patterns are concerned with algorithms and the assignment of responsibilities between objects.
- Chain of Responsibility
- Template Method
- The specification pattern encapsulates business logic in a Boolean algorithm outside of a business entity.
- Cam be chained together to form more flexible complex business logic.
- Separates business logic that is used to match an object from the actual object
Layer Supertype Pattern
- Defines an object that acts as the base class for all types in it’s layer
- Based on inheritance
- Can remove duplication and centralize logic