The classic GoF design patterns are grouped into which three categories?
Options
- Fast, medium and slow, by how quickly they run
- Creational, Structural and Behavioral (Correct option)
- Frontend, backend and database patterns
- Public, private and protected patterns
Answer
Creational (how objects are created), Structural (how objects are combined), Behavioral (how objects communicate)
Why
The book "Design Patterns" by the Gang of Four (GoF) lists 23 patterns in three groups:
- Creational: Singleton, Factory Method, Abstract Factory, Builder, Prototype. They control object creation.
- Structural: Adapter, Decorator, Facade, Proxy, Composite, Bridge, Flyweight. They combine classes into larger structures.
- Behavioral: Strategy, Observer, Command, Template Method, State, Iterator, Chain of Responsibility. They define how objects interact.
A pattern is a proven solution to a recurring design problem, not code you copy.
Remember
Creational = create. Structural = compose. Behavioral = interact.