- Visualizing a Class
- Attributes
- Operations
- Attributes, Operations, and Visualization
- Responsibilities and Constraints
- Attached Notes
- Classes—What They Do and How to Find Them
- Summary
- Q&A
- Workshop
Attributes, Operations, and Visualization
We've been dealing with classes in isolation thus far and showing all the attributes and operations of a class. In practice, however, you'll show more than one class at a time. When you do that, it's typically not useful to always display all the attributes and operations. To do so might make the diagram way too busy. Instead, you can just show the classname and leave either the attribute area or the operation area empty (or leave them both empty), as Figure 3.9 shows.
Figure 3.9 In practice, you don't always show all of a class's attributes and operations.
Sometimes it might be helpful to show some (but not all) of the attributes or operations. To indicate that you've only shown some of them, you follow the list of the ones you've shown with three dots ". . . ". This is called an ellipsis, and omitting some or all of the attributes or operations is called eliding a class. Figure 3.10 shows the use of an ellipsis.
Figure 3.10 An ellipsis indicates that the displayed attributes or operations aren't the whole set.
If you have a long list of attributes or operations, you can use a keyword to organize in ways that will make the list comprehensible. As I mentioned in Hour 1, a keyword is enclosed inside two pairs of small angle brackets called guillemets. For an attribute list, you can use a keyword as a heading for a subset of the attributes, as in Figure 3.11.
Figure 3.11 You can use a keyword to organize a list of attributes or operations.