One Pager Cheat Sheet
- Design Patterns are general and reusable solutions that help developers avoid
reinventing the wheel
, and should beused judiciously
to provide the most benefit. Design patterns were originally developed by architects, and gained popularity when codified by the "Gang of Four" in 1994 as elements of reusable object-oriented software.
- There are 23 patterns from the Gang of Four book, divided into 3 categories (Creational, Structural and Behavioral) with The Big Ball of Mud being one of the most commonly used design patterns.
- The Singleton design pattern ensures that only one instance of a class is created, and provides a global point of access to that instance.
- The Factory Method pattern makes it easy to create instances of objects without exposing the instantiation logic, which is especially useful for non-trivial objects.
- The Builder pattern is a useful solution for when an object needs to be customized through a non-trivial, multi-step process and as an alternative to numerous parameters in the constructor.
- The Adapter pattern helps to bridge the gap between incompatible objects by transforming one object's interface into an interface expected by the other object, similar to physical adapters used in hardware.
- The Strategy pattern allows for a family of related algorithms to be defined, and for a decision of which one to use at runtime to be made based on user input, thereby avoiding
complex chains of conditions
, and making it possible to switch strategies at call site in order to adapt to different situations, while related techniques such asDependency Injection
offer added benefits. - The Observer pattern allows an object (the subject) to let others (the observers) know of any changes to its state by establishing a one-to-many dependency between them.
- The Visitor pattern lets you add operations to objects without modifying them, separating an algorithm from the
object structure
on which it operates, and avoidingconditional blocks
andtype checks
. - The concept of anti-patterns, which can evolve from overused design patterns, as well as architectural patterns such as
MVC
,MVVM
,ESB
andP2P
, are related to patterns in software development. - With resources such as
Awesome Software and Architectural Design Patterns
,Design Patterns for Humans
andLearning JavaScript Design Patterns
by Addy Osmani, as well asOODesign.com
and theGoF Design Patterns Reference
, anyone can deepen their understanding of Design Patterns.