We provide a set of UML class diagrams for solutions that are coded in Java or C++. These diagrams are a helpful aid to understanding code that takes advantage of class inheritance and polymorphism. Figure 3-3 contains a sample class diagram showing the relationship between a superclass
SegmentTreeNode and two subclasses,
StoredIntervalsNode, that extend
SegmentTreeNode using inheritance (as identified by the arrows terminating in triangles). Each class box has two parts: the upper part lists instance variables, and the lower part lists instance methods. The leading symbols for each declared attribute or method are significant:
Declares that the attribute or method is visible to the class or any of its subclasses; if the underlying implementation is Java, then the attribute or method is also visible to classes within the same package. Note that in our C++ implementations, we do not use multiple inheritance or friend classes, so the semantics are nearly identical.
Declares that the attribute or method is visible only to classes within the same package; used only by Java designs.
Declares that the attribute is visible only to the class itself in which the attribute is defined. We intentionally do not list in the class diagram any private methods that may exist.
Declares that the attribute or method is visible and accessible to anyone. Public attributes are, in general, assumed to be "final" ...