A Pattern is a solution to a problem in a context.
Refactoring is the process of making changes to your code to improve the way it is organized. The goal is to improve its structure, not change its behavior. This is a great time to reexamine your design to see if it might be better structured with patterns
If you have a practical need to support change in a design today, go ahead and employ a pattern to handle that change. However, if the reason is only hypothetical, don’t add the pattern, it is only going to add complexity to your system, and you might never need it!
An Anti-Pattern tells you how to go from a problem to a BAD solution.
- Encapsulate what varies.
- Favor composition over inheritance.
- Abstraction Encapsulation Polymorphism Inheritance
- Program to interfaces, not implementations.
- Strive for loosely coupled designs between objects that interact.
- Classes should be open for extension but closed for modification.
- Depend on abstractions. Do not depend on concrete classes.
- Only talk to your friends. Don’t call us, we’ll call you.
- A class should have only one reason to change.