No this is not an “art of living” post where I talk about how you can improve your life with doing more yoga and taking less stress :). I rather wanted to focus on how to reduce the impact of changes in the software system and elaborate the design principles that help reduce the re-work and clutter that usually happens in the later stages of the development cycle .. so a better life for the system and thus for the developer as well 😉
Some of the "must have – must follow" design principles
- Encapsulate what varies = Strategy pattern.
- Favor Composition over inheritance = Strategy pattern.
- Program to interfaces not implementations = Strategy pattern.
- Strive for loosely coupled designs between objects that interact = Observer Pattern.
- The Open Closed Principle: Classes should be open for extension and closed for modification = Decorator pattern.
- Depend on abstracts, do not depend on concrete classes = Factory Pattern.
- Only talk to your friends = The Facade Pattern
- Always let the higher layers call the lower layer and not vice versa = Template Pattern
- The Single responsibility principle – A class should have only one reason to change.
*Inspired from the Head First Design Patterns book