|< Free Open Study >|
Chapter 4 The Relationships Between Classes and Objects
Heuristic 4.1 Minimize the number of classes with which another class collaborates.
Heuristic 4.2 Minimize the number of message sends between a class and its collaborator.
Heuristic 4.3 Minimize the amount of collaboration between a class and its collaborator, that is, the number of different messages sent.
Heuristic 4.4 Minimize fanout in a class, that is, the product of the number of messages defined by the class and the messages they send.
Heuristic 4.5 If a class contains objects of another class, then the containing class should be sending messages to the contained objects, that is, the containment relationship should always imply a uses relationship.
Heuristic 4.6 Most of the methods defined on a class should be using most of the data members most of the time.
Heuristic 4.7 Classes should not contain more objects than a developer can fit in his or her short-term memory. A favorite value for this number is six.
Heuristic 4.8 Distribute system intelligence vertically down narrow and deep containment hierarchies.
Heuristic 4.9 When implementing semantic constraints, it is best to implement them in terms of the class definition. Often this will lead to a proliferation of classes, in which case the constraint must be implemented in the behavior of the class梪sually, but not necessarily, in the constructor.
Heuristic 4.10 When implementing semantic constraints in the constructor of a class, place the constraint test in the constructor as far down a containment hierarchy as the domain allows.
Heuristic 4.11 The semantic information on which a constraint is based is best placed in a central, third-party object when that information is volatile.
Heuristic 4.12 The semantic information on which a constraint is based is best decentralized among the classes involved in the constraint when that information is stable.
Heuristic 4.13 A class must know what it contains, but it should never know who contains it.
Heuristic 4.14 Objects that share lexical scope梩hose contained in the same containing class梥hould not have uses relationships between them.
|< Free Open Study >|