A collection of design patterns in modern C++ based on Dmitri Nesteruk Udemy course Design Patterns in Modern C++.
- Single Responsibility Principle
- A class should only have one reason to change
- Separation of concerns - different classes handling different, independent tasks/problems.
- Open-Closed Principle
- Classes should be open for extension but closed for modification.
- Liskov Substitution Principle
- You should always be able to substitutes a base type for a subtype.
- Interface Segregation Principle
- Don't put too much into an interface; split into separate interfaces.
- YAGNI - You Ain't Going to Need It.
- Dependency Inversion Principle
- High-level modules should not depend upon low-level ones; use abstractions.
Design Patterns are typically split into three categories. This is called Gamma Categorization after Erick Gamma, one of the GoF authors.
- Creational Patterns
- Deal with the creation (construction) of objects
- Explicit (constructor) vs. implicit (DI, reflection, etc.)
- Wholesale (single statement) vs. piecewise (step-by-step)
- Structural Patterns
- Concerned with the structure (e.g., class members)
- Many patterns are wrappers that mimic the underlying class' interface
- Stress the importance of good API design
- Behavioral Patterns
- They are all different; no central theme