UML Essentials, Elements, and Artifacts
- 1 Elements, Viewpoints, and Views
- 2 Packages
- 3 Extensions
- 4 Symbols
- 5 Lines
- 6 Diagrams
- 7 Further Reading
There aren't enough symbols to cover all the subtly different things we want to say.
—Desmond D'Souza and Alan Wills (1998, 371)
This chapter provides you with a high-level summary of the main elements and artifacts of the UML—enough to get started with the pattern language.
Obviously, a single chapter is scarcely adequate to even begin the exercise of learning about the UML. But there are many good books out there that can provide an introductory service for those not already using the UML, and this book isn't meant to cover their territory. Anyone with a working knowledge of the UML can skim this chapter with the proviso that it provides information based on the 1.3 beta version of the UML Specification (Rational Software Corporation 1999), and so it may be useful as an update.
Also, I take a somewhat different approach than is typical for introductions. One difference is that this chapter, like this book and the UML itself, is process-independent. And, where it's important to illustrate anomalies and differences that come from the different ways that processes can interpret the UML, I use Rational's Unified Process and Desmond D'Souza and Alan Wills' book, Objects, Components and Frameworks with UML: The Catalysis Approach (1998) as examples of almost orthogonal processes. I've tried to distinguish between process-specific uses and notations and those that are "vanilla" UML. Where there are notable anomalies, I draw attention to them.
The other way that this chapter is different is that I focus on the packaging and notational side of the UML rather than the detailed semantics of the UML constructs. I do this for two reasons:
The packaging, organizing, and drawing side of the UML seems to be underrepresented in the literature. How to go about making a model has taken a back seat to using the UML in creating development artifacts—a subtle but significant difference.
For a book like this, which is aimed at modeling rather than programming, understanding packaging and notation is crucial to using the UML effectively as a tool, just as knowing the syntax is crucial to using a programming language effectively. This chapter aims to clarify what has been a notable amount of confusion in this area, in writings about the UML.
For the most part, the semantics of the UML are sufficiently object-oriented to present little difficulty to anyone with a programming background in any of the object-oriented languages. Of course, some aspects of the UML semantics that are specific to modeling or that are idiomatic to the UML need to be explained, and I'll cover these as well.
Like patterns, a summary such as this one doesn't benefit from inspired originality or novel insights. So, I relied on tried-and-true sources, and I reworked existing material, rather than providing a new way of looking at the innards of the UML. The description that follows is primarily drawn from the UML Specification, Version 1.3 (Rational Software Corporation 1999), fleshed out by readings from UML Distilled: Applying the Standard Object Modeling Language (Fowler, Scott, and Jacobson 1997) and Objects, Components and Frameworks with UML: The Catalysis Approach (D'Souza and Wills 1998).
3.1 Elements, Viewpoints, and Views
The idea of a view is a key one in the UML: It provides the basis for the UML notion of a model. However, it is not a formal construct in the UML (although it is in the Rational Unified Process [RUP], a distinction that is typically muddied by writers about the UML). Instead, it acts as an informal concept that helps situate the role—and responsibilities—of the modeler.
In the UML, a model is a complete representation of a system from a particular viewpoint (that is, an aggregation of a set of views from specific perspectives). At the same time, systems are logically composed of many nearly independent models, representing many different viewpoints; and they can be physically composed of many independent subsystems, each of which can also be treated as a system for modeling purposes.
A system itself is implicitly represented by a top-level model with subsidiary models representing specialized views. Each model is made up of diagrams and text. The UML Specification describes diagrams as "views of a model," each representing a particular perspective that the overall model aggregates and integrates (Rational Software Corporation 1999). All of this applies recursively to subsystems as well.
The perspective that a model represents is a combination of the model's purpose and the level of detail it provides. Any system can contain a myriad of viewpoints and models, which depend on the role of each viewer, the conceptual stance he or she brings to the viewing, and the ultimate purpose of the view. Any viewpoint can be expressed by a myriad of views and diagrams, depending on the interests of the audience being addressed.
The modeler represents these views, wearing different hats in turn, and adopting different viewpoints. A user's view will end up being expressed differently depending on whether the audience is senior management or a technical person. A management perspective might result in a management model that emphasizes architecture and minimizes technical detail.
At the most abstract, a system should be modeled from at least two viewpoints:
Looking at the outside world—an interpreted reality
Looking at the product—a constructed reality
As modelers, in order to build a system, we model our understanding of the context, requirements, practices, and constraints to ensure that we have the problem and problem setting right. We then model the architecture, specifications, design, implementation, and deployment of what the builders should build. The second viewpoint provides a blueprint that builders can work from and the documentation that management needs to get the product built, keep it working, and make it useful.
The advantage an object-oriented approach brings to modeling is that it allows a modeler to "bridge the chasm" (Jacobson, Booch, and Rumbaugh 1998a, 7) between the analysis and design models by providing a semantically consistent conceptual framework, regardless of the viewpoint involved. Things in the real world are represented as objects, in the same way that things in the constructed world are. The modeling modes are still distinct, but the language is very much the same.
Naturally, in an iterative development process, even the barrier between modeling modes is permeable, and there's a constant to-and-fro, as opposed to rigid distinctions. In fact, as I will discuss in Chapter 11, "Putting It All Together: Reflecting on the Work of Design," proper design practice requires the interweaving of these two modes.
Beyond the simple need for a minimum of two viewpoints, additional viewpoints can be added to the picture, depending on the expressive granularity the modeler feels is warranted. Individual processes will treat the idea of views differently, making them formal constructs (for example, RUP) or leaving them as informal concepts (for example, Objects, Components and Frameworks with UML: The Catalysis Approach [D'Souza and Wills 1998]). The UML also assumes that you may want to create your own kinds of diagrams and your own kinds of models, and you may want to extend the UML in various ways to establish your own local modeling dialect.
3.1.1 Models and Model Elements
To repeat: A UML model is an abstraction, a complete representation of a physical system. Models are about things, relationships, behaviors, and interactions in a system. Equally important, models are about how to organize this information because conceptual chunking is an important tool for successful abstracting.
The UML itself distinguishes two types of models:
Structural models—Represent the pieces of a system and their relationships.
Dynamic models—Represent the behavior of the elements of the system and their interactions.
Models are made up of model elements. Model elements are named uniquely in the context of a given namespace (usually a package) and have visibility, which defines how they can be used (and reused) by other model elements.
Visibility determines the way individual elements can connect with each other. Therefore, it is a critical part of managing the complexity of models via information hiding. Decisions about visibility can be powerful factors influencing decisions about the logical organization of models. It is one of the ways in which the UML is distinctly different from previous generations of modeling languages and tools—by leveraging and extending the notion of visibility from object-oriented languages themselves.
In the UML, model elements may be visible in one of three ways:
Public—Any outside model element can see the model element.
Protected—Any descendent can see the model element.
Private—Only the model element itself, its constituent parts, and the model elements nested within it can see it.
Individual parts of the UML adjust this general notion of visibility to suit specific circumstances. See the discussion of package visibility in Section 3.2, "Packages," later in this chapter.
Models and model elements are rendered graphically in diagrams and textually in specifications, and they are organized in packages.
In UML notation, model things are expressed as symbols or icons, and relationships and interactions are typically expressed by using various kinds of adorned lines. The lines themselves aren't just passive, decorated connectors; in the UML, they're also symbols with semantic content and underlying rules. And, as organizational elements, neither models nor diagrams have a specific notational form (that is, the UML symbol)—only packages do.
Of course, it's not the rendering of the individual elements that provides the meaning and meat to a model, but the way they all connect. The connection between a model, its diagrams, and their parts—the connection between a viewpoint and expressed views—is almost rhetorical. Intention, attention, and focus provide differences in level of detail, formality, content, and manner of presentation.
Models aren't just diagrams; in the UML, the diagrams are only the visual rendering of the model. Underlying the graphics of a model are the specifications of the model elements. These are composed in text, and may be a mix of the formal and the informal. The text is as important as the diagrams and in some cases more so: use cases are an example (see Section 3.6.2, "Use Case Diagram," later in this chapter). The UML Specification itself is an example of a model (although not a good one, if judged by its clarity and communicative effectiveness).
Semantically, diagrams express views of a model (that is, subsets of the viewpoint that each model represents). An individual model element can be presented in one or many of the diagrams for a model; in other words, a model element can be presented in many different ways and in many diagrams—but it must be presented in at least one diagram in one way.
Diagrams don't have any special shape assigned to them; they can be free-floating, bounded by a box, or contained within a package. Some other considerations are as follows:
Neither geometry nor "geography" has much significance in a UML diagram. For the most part, a symbol's size or relative location generally has no semantic content, except for diagrams that have a time dimension.
Diagrams are all two-dimensional because of the current limits imposed by available technology and tools, although some shapes are nominally three-dimensional, rendered in two dimensions (cubes, for example).
Text can be used liberally within a diagram. Examples include expressing rules and, within symbols, identifying attributes.
Finally (for this introduction), the UML Specification (Rational Software Corporation 1999) highlights three kinds of visual relationships in diagrams:
Connection—Lines connect icons and symbols, forming connecting paths. Paths are always attached to symbols at both ends (that is, no dangling lines are allowed).
Containment—Boxes, circles, and other fully enclosed shapes contain symbols, icons, and lines.
Visual attachment—Elements that are close together may have a relationship suggested by their proximity. For example, a name above a line or next to a box may be interpreted as applying to the line or box.