(1) All data should be hidden inside the class in which it is located.
(2) The consumer of a class must rely on the common interface of the class, but the class cannot rely on its users.
(3) Minimize the message in the class protocol.
(4) Implement the most basic public interfaces understood by all classes [for example, copy operations (deep and shallow copies), equality judgments, correct output, parsing from ASCII, and so on].
(5) Do not place implementation details (such as private functions that place common code) into the public interface of the class.
If the two methods of a class have a piece of common code, you can create a private function that prevents these common code.
(6) Do not disturb the public interface of the class with something that the user cannot use or is not interested in.
(7) The class should be 0 coupled, or only the coupling relationship should be derived. That is, a class has nothing to do with another class, or it uses only operations in the public interface of another class.
(8) A class should only represent a critical abstraction.
All classes in a package should be closed together for changes of the same nature. If a change affects a package, it will have an effect on all classes in the package and not on the other packages.
(9) Place the relevant data and behavior in a centralized position.
Designers should be aware of objects that fetch data from other objects through a get operation. This type of behavior implies that the rule of thumb has been violated.
(10) To put irrelevant information in another class (i.e., the behavior of mutual communication).
depend on the direction of stability.
(11) Make sure that the abstract concept you are modeling is a class, not just the role of the object.
(12) Distribute the system function as uniformly as possible in the horizontal direction, namely: according to the design, the top-level class should share the work uniformly.
(13) Do not create a universal class/object in your system. Be especially careful with names that contain driver, Manager, System, and Susystem classes.
Plan an interface instead of implementing an interface.
(14) Be more careful with classes that define a large number of access methods in the public interface. A large number of access methods means that the relevant data and behavior are not centrally stored.
(15) Be more careful with classes that contain too much communication behavior. P31
Another manifestation of this problem is the creation of many get and set functions in the public interface of the classes in your application.
(16) In an application composed of an object-oriented model interacting with the user interface, the model should not be dependent on the interface, and the interface should be dependent on the model.
(17) modeling as much as possible in the real world (we often violate this principle in order to comply with the principle of system function distribution, to avoid the principle of universal class and to centralize the relevant data and behavior).
(18) Remove unwanted classes from your design.
In general, we will demote this class to a property.
(19) Remove the class outside the system.
Classes outside the system are characterized by an abstraction that sends messages only to the system domain but does not accept messages from other classes in the system domain.
(20) Do not turn the operation into a class. Question any class whose name is a verb or a derived automatic word, especially one that has only a meaningful behavior. Consider whether the meaningful behavior should be migrated to a class that already exists or has not yet been discovered.