We mentioned in earlier lessons that things fall into categories - classes. The UML class diagram consists of several classes conected with relationships. But how UML represents a class?
The rectangle is the icon for the class. The name of the class is, by
convention, a word with an initial uppercase letter. It appears near the top of the
rectangle. If your class name has more than one word name, then join the words together
and capitalize the first letter of the every word.
Class name is written at the top of the rectangle |
An attribute is a property of a class. It describes a range of values that the property may hold in objects of the class. A class may have zero or more attributes.
A one-word attribute name is written in lowercase letter. If the name
consists of more than one word, the words are joined and each word other than the first
word begins with an uppercase letter. The list of attribute names begins below a line
separating them from the class name.
In the class icon, you can specify a type for each attribute's value (string, floating-point, number, integer, boolean or user defined types). Also you can indicate a default value for an attribute. |
An operation is something that a class can do, or that you (or naother class) can do to a class.
Like
an attribute name, an operation's name is written in lowercase letter. If the name
consists of more than one word, the words are joined and each word except the first
word begins with an uppercase letter. The list of operations begins below a line
separating
operations from the attributes.
Also operations may have some aditional information. In the parentheses that follow an operation name, you can show the parameter that the operation works on, along with the parameter's type. If the operation is function, then we must specify the type of the returned value. |
Other additional features that can be attached to attributes of the class are constraints
and notes.
Constraints are free form text enclosed in
braces. The backeted text specifies one or more rules the class follows.
Notes usually are attached to attributes as
well as operations, and they give aditional information to a class. A note can contain a
graphic as well as text.
How can we derives classes from interviewing the clients?
In conversations with clients, be alert to the nouns they use to describe the
entities in their business. Those nouns will become the classes in your model. Be alert
also to the verbs that you hear, because these will constitute the operations in those
classes. The attributes will emerge as nouns related to the class nouns.