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 3—How to Approach the <strong>UML</strong> 29<br />

Victor : Person<br />

name : Victor<br />

phone : 555-555-5555<br />

call(integer): boolean<br />

Figure 3-5 Victor on the left (hard at work); abstraction of Victor on the right<br />

(an object icon)<br />

Here’s the crux of the matter: An abstraction benefits you only in so far as it describes<br />

the information you need in order to solve a problem. So when you create an abstraction,<br />

you must first make certain that you know why you need it.<br />

My own working definition for creating an abstraction is: representing something in the<br />

real world in a useful manner to solve a specific problem. Usefulness is measured by how well<br />

it helps you solve the problem you are trying to solve.<br />

The representation is an object. The rules that define the representation make up a class.<br />

For comparison, think of the word apple in a dictionary and an apple in your hand. In software,<br />

the definition in the dictionary is a class, and the apple in your hand is an object. <strong>To</strong><br />

make objects from classes, you must use the class definition like a template or a mold.<br />

Although each object may vary somewhat, all objects of the same class must conform to<br />

the class definition. That’s why some people say that an object is an instance of a class.<br />

An object is created, manufactured, or instantiated (made real) from the class definition.<br />

What an object knows<br />

<strong>To</strong> function properly, every object has to know two kinds of information and two types of<br />

behavior.<br />

Information<br />

First, you can say that an object knows about itself. In other words, there is information<br />

that describes the object. For example, the pencils on my desk have a length, hardness,<br />

brand name, eraser, and so on. A book has pages, a cover, a title, an author, and so on. This<br />

is some of the information that would eventually be captured and manipulated in files or<br />

databases.<br />

Second, you can say that an object knows its own current condition. This condition is<br />

formally called the state of the object. Simply put, the state of an object is a description of<br />

the properties of the object during a particular period of time. Consequently, when any of<br />

the properties of the object change, the state of the object is said to change.<br />

An object can describe itself.<br />

An object knows its current condition (or state).

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

Saved successfully!

Ooh no, something went wrong!