Home > Articles > Programming

  • Print
  • + Share This
This chapter is from the book

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 would make the diagram way too busy. Instead, you can just show the class name 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 stereotype to organize in ways that will make the list comprehensible. A stereotype is the UML's way of enabling you to extend it: It allows you to create new elements that are specific to the particular problem you're trying to solve. As I mentioned in Hour 1, you show a stereotype as a name enclosed inside two pairs of small angle brackets called guillemets. For an attribute list, you can use a stereotype as a heading for a subset of the attributes, as in Figure 3.11.

Figure 3.11 You can use a stereotype to organize a list of attributes or operations.


The stereotype is a flexible construct. You can use it in many different ways. For example, you can use it above the name of a class in a class icon to indicate something about the role that class plays. I'll have more to say about stereotypes in Hour 14, "Understanding the Foundations of the UML."

  • + Share This
  • 🔖 Save To Your Account