Ood design principles Overview:
Robert tcecilmartin,Bertrandmeyer,Barbaraliskov11 object-oriented design principles are put forward, which are regarded as the good bible by Object-Oriented designers. They can see their original text below:
Http://c2.com/cgi/wiki? Principlesofobjectorienteddesign
Http://www.objectmentor.com/
Class Design Principles ):
- Single Responsibility Principle (SRP ):A class should have only one reason to change.(SRP) The single responsibility principle:A class shoshould have only one reason to change.
- OCP ):Software entities (classes, modules, functions, etc.) should be extensible, but cannot be modified.
-
(OCP) The open-closed principle:Software entities (classes, modules, functions, etc.) shocould be open for extension, but closed for modification.
- Liskov replacement principle (LSP ):The subclass must be applicable to the base class, that is, the subclass must be able to replace the base class, otherwise.
-
(LSP) The liskov substitution principle:Subtypes must be substitutable for their base types.
-
- Dependency inversion principle (DIP ):Abstraction should not depend on details, but on abstraction.(DIP) the dependency inversion principle:Specified actions shoshould not depend upon details. Details shoshould depend upon specified actions.
- Interface isolation principle (ISP ):Customers only need to focus on the interfaces they need, rather than forcing customers to rely on methods they don't need.
-
(ISP) the interface segregation principle:Clients shoshould not be forced to depend upon methods that they do not use. Interfaces belong to clients, not to hierarchies.
Principles of package cohesion ):
- Reuse release Equivalence Principle (REP ):The granularity of reuse is the publishing granularity.
-
(REP) the reuse/release equivalency principle:The granule of reuse is the granule of release.
- Common blocking principle (CCP ):All classes in the package should be closed for changes to the same class nature.(CCP) The common closure principle:He classes in a package shoshould be closed together against the same kinds of changes. A change that affects a closed package affects all the classes in that package and no other packages.
- Common Reuse Principle (CRP ):All classes in a package should be reused together.
-
(CRP) The common Reuse Principle:The classes in a package are reused together. If you reuse one of the classes in the package, you reuse them all.
Principles of package coupling ):
- No-ring dependency principle (ADP ):The package dependency graph does not allow loops.
-
(ADP) The Acyclic Dependencies Principle:Allow no cycles in the package dependency graph.
- Stable dependency principle (SDP ):Dependency in a stable direction.(SDP) the Stable Dependencies Principle:Depend in the direction of stability.
- Stable abstraction principle (SAP ):The abstraction level of the package should be consistent with its stability.
-
(SAP) the stable role action principle:A package shoshould be as abstract as it is stable.