HTML and CSS Reference
In-Depth Information
A basic class diagram for MoMemo is shown in Figure 8-2.
Figure 8-2.
Classes in a class diagram
As you can see from Figure 8-2, each box shows a name at the top (e.g.,
Movie
,
Actor
, etc.), which represents the name of each class. Just below the box name
are several lines prefixed with a - symbol. These are attributes of the class. The
symbol before the name of the attribute dictates whether the attribute should be
public (+) or private (-). You can specify types as well as other properties for
attributes in UML class diagrams.
Just below the attributes, there is a line followed by a method name. In the
example in Figure 8-2, you can see that the only method for
Movie
is
isFavorite,
which returns a Boolean and determines whether the movie is a
favorite.
The black diamonds next to the class indicate that there is an association
between the
Movie
class and the
Actor
and
Video
classes. The black diamond
tells you that the association is a composite, meaning that the
Movie
class owns
an
Actor
and
Video
, and that the
Actor
and/or
Video
cannot exist without the
Movie
within the context of this application. The composite association also says
that if the parent (
Movie
, in this case) dies, then child (
Actor
/
Video
) will cease to
exist. It's always important to remember that, when creating associations
between classes, they are made within the context of the application. There are
other types of associations, which are listed in Table 8-1.