Design Principles and Design Patterns
Writing on this subject at his website http://www.objectmentor.com/, Robert C. Martin identifies a set of design principles and design patterns that all software development project managers should understand
(see http://www.objectmentor.com/resources/articles/Principles_and_Patterns.pdf )
Here they are in summary:
Principles of Object Oriented Class Design
- The Open Closed Principle (OCP) - A module should be open for extension but closed for modification. The correct use of this principle and its related techniques allow developers to add new features to existing code without changing the existing code and by only adding new code. It is always better that changes not propogate into existing code that already works. If you don't have to change working code, you aren't likely to break it.
- The Liskov Substitution Principle (LSP) - Subclasses should be substitutable for their base classes.
- The Dependency Inversion Principle (DIP) - Depend upon abstraction. Do not depend upon concretions. Dependency inversion is the strategy of depending upon interfaces or abstract functions and classes rather than upon concrete functions and classes. Every dependency in the design should target an interface, or an abstract class. No dependency should target a concrete class. Concrete things change alot; abstract things change much less frequently.
- The Interface Segregation Principle (ISP) - Many client-specific interfaces are better than one general purpose interface. If you have a class that has several clients, rather than loading the class with all the methods that the clients need, create specific interfaces for each client and multiply inherit them into the class.
Principles of Package Architecture (aka, Package Cohesion Principles)
- The Release Reuse Equivalency Principle (REP) - The granule of reuse is the granule of release.
- The Common Closure Principle (CCP) - Classes that change together belong together.
- The Common Reuse Principle (CRP) - Classes that aren't reused together should not be grouped together.
- The Acyclic Dependencies Principle (ADP) - The dependencies between packages must not form cycles.
- The Stable Dependencies Principle (SDP) - Depend in the direction of stability.
- The Stable Abstractions Principle (SAP) - Stable packages should be abstract packages.
Patterns of Object Oriented Architecture
When following the principles described above to create object oriented architectures, one finds that one repeats the same structures over and over again. These repeating structures of design and architecture are known as design patterns. The essential definition of a design pattern is a well-worn and known good solution to a common problem. Design patterns are not new. Rather, they are old techniques that have shown their usefulness over a period of many years.
- Abstract Server
- Abstract Factory