01.01.2015 Views

UML Weekend Crash Course™ - To Parent Directory

UML Weekend Crash Course™ - To Parent Directory

UML Weekend Crash Course™ - To Parent Directory

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Session 9—Modeling the Static View: The Class Diagram 95<br />

Although other diagrams are necessary, remember that their primary purpose is to support<br />

the construction and testing of the Class diagram. Whenever another diagram reveals<br />

new or modified information about a class, the Class diagram must be updated to include<br />

the new information. If this new information is not passed on to the Class diagram, it will<br />

not be reflected in your code.<br />

The Object diagram<br />

The class defines the rules; the objects express the facts.<br />

The class defines what can be; the object describes what is.<br />

If the Class diagram says, “This is the way things should be,” but the Object diagram graphically<br />

demonstrates that “it just ain’t so,” then you have a very specific problem to track<br />

down. The reverse is true, too. The Object diagram can confirm that everything is working<br />

as it should. Session 13 walks you through an example of applying the Object diagram for<br />

just this purpose.<br />

Elements of the Class Definition<br />

The class symbol is comprised of three compartments (rectangular spaces) that contain distinct<br />

information needed to describe the properties of a single type of object.<br />

The name compartment uniquely defines a class (a type of object) within a package.<br />

Consequently, classes may have the same name if they reside in different packages.<br />

The attribute compartment contains all the data definitions.<br />

The operations compartment contains a definition for each behavior supported by<br />

this type of object.<br />

Tip<br />

Technically, the <strong>UML</strong> allows for user-defined compartments as well as the<br />

three standard ones, but I’ll leave that as an advanced topic for another book<br />

or for your own personal study of the <strong>UML</strong> specification.<br />

Sessions 10 and 11 present the rest of the notations that make up the Class diagram.<br />

Modeling an Attribute<br />

An attribute describes a piece of information that an object owns or knows about itself. <strong>To</strong><br />

use that information, you must assign a name and then specify the kind of information, or<br />

data type. Data types may be primitive data types supplied by a language, or abstract data<br />

types (types defined by the developer). In addition, each attribute may have rules constraining<br />

the values assigned to it. Often a default value helps to ensure that the attribute<br />

always contains valid, meaningful data.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!