Java Reference
In-Depth Information
Make a class diagram that shows the relationships between all the classes that you
discovered.
Start with inheritanceȌthe is-a relationship between classes. Is any class a
specialization of another? If so, draw inheritance arrows. Keep in mind that many
designs, especially for simple programs, don't use inheritance extensively.
The Ȓcollaboratorsȓ column of the CRC cards tell you which classes use others.
Draw usage arrows for the collaborators on the CRC cards.
Some dependency relationships give rise to aggregations. For each of the
dependency relationships, ask yourself: How does the object locate its
collaborator? Does it navigate to it directly because it stores a reference? In that
case, draw an aggregation arrow. Or is the collaborator a method parameter or
return value? Then simply draw a dependency arrow.
A DVANCED T OPIC 12.1: Attributes and Methods in UML
Diagrams
Sometimes it is useful to indicate class attributes and methods in a class diagram.
An attribute is an externally observable property that objects of a class have. For
example, name and price would be attributes of the Product class. Usually,
attributes correspond to instance variables. But they don't have toȌa class may
have a different way of organizing its data. For example, a
GregorianCalendar object from the Java library has attributes day, month ,
and year , and it would be appropriate to draw a UML diagram that shows these
attributes. However, the class doesn't actually have instance fields that store these
quantities. Instead, it internally represents all dates by counting the milliseconds
from January 1, 1970Ȍan implementation detail that a class user certainly doesn't
need to know about.
You can indicate attributes and methods in a class diagram by dividing a class
rectangle into three compartments, with the class name in the top, attributes in the
middle, and methods in the bottom (see Attributes and Methods in a Class
Diagram). You need not list all attributes and methods in a particular diagram. Just
list the ones that are helpful to understand whatever point you are making with a
particular diagram.
Search WWH ::




Custom Search