- 论坛徽章:
- 0
|
•类的详细描述:类是一个域和方法的命名集合,域持有数据的值,方法操作这些这些值。
•一个类建立了一个域的集合:它定义了一个对象的属性。属性的类型是其它类、原子数据类型(如boolean或int)和接口。
•类设计者应该可以合理化类属性间的关联。
•类名应该既可以反映属性的意义,又能代表类的行为。
•一个类必须支持所有它所定义的行为,包括在超类中定义的和在类所支持的接口中定义的。(不支持超类或接口方法的决定有时也合理。)
•一个类与其超类要有合理的关联。
•每个类方法的名字应当是一个好的方法行为的注释。
• A nuts-and-bolts description of a class is, "A class is a named collection of fields that
hold data values and methods that operate on those values" (Flanagan 1999b, p. 61).
• A class establishes a collection of fields: that is, it defines the attributes of an object.
The attribute types are other classes, primitive data types, such as boolean and int,
or interfaces.
• A class designer should be able to justify how a class's attributes are related.
• The name of a class should reflect the meaning of the class both as a collection of
attributes and with respect to the class's behavior.
• A class must support all the behaviors it defines, as well as all those in superclasses,
and all methods in interfaces that the class implements. (A decision to not support a
superclass or an interface method is occasionally justifiable.)
• A class should have a justifiable relationship to its superclass.
• The name of each of a class's methods should be a good commentary on what the
method does.
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u2/68079/showart_1726711.html |
|