1 | Introduction to Object-Oriented Programming
techniques to communicate their designs more effectively. The Unified Modeling
Language (UML) contains a set of graphical notations for building diagrams that
depict various aspects of
the
system model. The UML is used extensively through-
out the software development industiy, so it is important that you understand
how to use UML diagrams to express and interpret object-oriented designs.
Throughout the remainder of this book, we will examine the usage types of vari-
ous UML diagrams at the end of each chapter. Our discussions will be based on
version 2.0 of the UML standard
3
. In this chapter, let's begin by looking at the
class diagram. For now, we will simply reinforce the concepts covered in this
introductoiy chapter. In Chapter 5, Inheritance, and Chapter 6, Polymorphism,
more advanced features of
class
diagrams will be considered.
A class diagram is used to illustrate the static architecture of an object-oriented
system. Here, you can depict the various classes used in the system, as well as
their relationships. Figure 1.6 shows a simple class diagram that describes a
scaled-down model of a sales order system used to process orders for an e-com-
merce website. In the following subsections, we will consider some of the basic
features of
a
UML class diagram.
1.6.1 Classes
The diagram in Figure 1.6 contains five classes: Order, Order Item, Product, Cus-
tomer, and Address. Classes are represented in class diagrams as rectangular boxes
partitioned into three sections: the top section contains the class name, the mid-
dle section contains the attributes associated with the class, and the bottom sec-
tion contains the operations (or methods) of the class (see Figure 1.7).
Of course, the rules here are not very strict. For example, in the diagram shown
in Figure 1.6, no operations are defined for class Address. This could be because
there were no operations identified for this class when it was designed, or the cre-
ator of this diagram thought that the operations were insignificant when describ-
ing the system architecture. The point is to not get too carried away with the
details because this can complicate the model to the point that the diagram is not
readable.
3 The UMI. standard is maintained by the Object Management Croup (OMG). For more informa-
tion on the OMG. check out http://www.uml.org.
34