- Class hierarchies reflect subclasssuperclass relations among classes.
- An instance can inherit instance variables and methods not only
from the class to which it belongs, but also from all that class's
superclasses.
- When a subclasssuperclass chain contains multiple methods with the
same name, the one closest to the receiver in the subclasssuperclass
chain is the one that is employed. All others are overridden.
- If you want to create a class hierarchy, then draw a diagram that
reflects natural categories, and use the diagram to help ensure the following:
- There is no unnecessary
duplication of instance variables or methods.
- Each instance variable and each method defined in a class is useful in
all that class's subclasses.
If you want to define a predicate that tests instances for class
membership, then instantiate the following method pattern for the
lowest class in the class hierarchy that is a superclass of all classes
whose instances are possible receivers of the predicate:
predicate name
^ false
and then instantiate the following method pattern for the class itself:
predicate name
^ true