Design Pattern
Pronunciationdih-ZYN PAT-ern
Definition
A proven, reusable solution to a common design problem, with a name everyone knows, such as Singleton, Factory, or Observer.
Where you hear it
Interviews, code reviews, and architecture talks.
Examples
This is the Observer pattern: subscribers get notified on every change.
Do not force a pattern where a simple function is enough.
The shop uses a factory pattern to create the right payment handler for each country.
Common mistake
Using patterns just to look advanced. Use one only when it solves a real problem.
Don't confuse with
Design patterns are often confused with architectural patterns; while a design pattern solves a specific problem within a single module or class, an architectural pattern provides a high-level strategy for the structure of the entire application.
Say it at work
- In a meeting or chat
I think we should use the Strategy design pattern here to make our validation logic more flexible.
- In an email or ticket
Please review the pull request, as I have refactored the module to implement the Factory design pattern.
Keep exploring
More in Architecture & Design