这里先将平时看书时记下的一些OO设计的原理,规则等整理了一下,罗列出来:
OO Basic
Abstraction
Encapsulation
Inheritance
Polymorphism
OO Objective
Reusable
Extensible
Maintainable
OO Bad Smells
Fragility
Rigidity
Immobility
Viscosity
OO Principles
SRP -- The Single Responsibility Principle.
A class should have only one reason to change.
OCP -- The Open Closed Principle.
Software entity should only be open for extension but
closed for modification.
LSP -- The Liskov Substitution Principle.
Subclasses should be substitutable for their base classes.
DIP -- The Dependency Inversion Principle.
Depend upon Abstractions. Do not depend upon
concretions.
ISP -- The Interface Segregation Principle.
Many client specific interfaces are better than one
general purpose interface
LoD -- The Law of Demeter
Any object receiving a message in a given method must
be one of a restricted set of objects.
CARP:
OO Rules
Rule1: Design to interfaces not implementation
Rule2: Favor composition over inheritance
Rule3: Encapsulate what varies
Rule4: Only tall to your friends
Rule5: Don't call us, we'll call you
Rule6: Depends on Abstraction not concrete class
Rule7: A Class should have only one reason to change
Rule8: Strive for loosely coupled designs between objects
that interact
Rule9: Strive for high cohesion
Rule10: Decoupling a problem domain into responsibility
Principles of Package Architecture
REP-- The Reuse Release Equivalency Principle.
The granule of reuse is the granule of release.
CCP-- The Common Closure Principle Principle.
Classes that change together, belong together.
CRP-- The Common Reuse Principle.
Classes that aren't reused together should not be grouped together.
ADP-- The Acyclic Dependencies Principle.
The dependencies betwen packages must not form cycles.
SDP-- The Stable Dependencies Principle.
Depend in the direction of stability.
SAP-- The Stable Abstractions Principle.
Stable packages should be abstract packages.
(To be continue…)
No comments:
Post a Comment