Few Books
Design patterns are optimized, reusable solutions to the programming problems that we encounter every day.
You have a problem statement - and you have a solution
Do not force design pattern
Understand how design patterns are defined in first place, and help yourself to come up with a variant of a solution.
Here comes some philosophical rant?
Pattern - is a solution to a problem, based on principle(s) and a valid context.
A fundamental truth or proposition that serves as the foundation for a system of belief or behavior or chain of a reasoning
Software Design Principle or Object Oriented Principles or any other principles
Patterns to understand where is problem in coding
| Code Smell | Refactoring Pattern |
|---|---|
| Alternative Classes with Different Interfaces | Unify Interfaces with Adapter Rename Method Move Method |
| Combinatorial Explosion | Replace Implicit Language with Interpreter |
| Comments (a.k.a. Deodorant) | Rename Method Extract Method Introduce Assertion |
| Conditional Complexity | Introduce Null Object Move Establishment to Decorator Replace Condition Logic to Strategy Replace State Altering Condition with State |
| Data Class | Move Method Encapsulate Field Encapsulate Collection |
| Data Clumps | Extract Class Preserve Whole Object Introduce Parameter Object |
| Divergent Change | Extract Class |
| Feature Envy | Extract Method Move Method Move Field |
| Code Smell | Refactoring Pattern |
|---|---|
| Duplicate Code | Chain Constructors Extract Composite Extract Method Extract Class Form Template Method Introduce Null Object Introduce Polymorphic Creation with Factory Method Pull Up Method Pull Up Field Replace One/Many Distinctions with Composite Substitue Algorithm Unify Interfaces with Adapter |
| FreeLoader (Lazy Class) | Collapse Hierarchy Inline Class Inline Singleton |
| Inappropriate Intimacy | Move Method Move Field Change Bidirectional Association to Unidirectional Association Extract Class Hide Delegate Replace Inheritance with Delegation |