Attributes and Methods

Besides presenting the structure of the class, the class diagram also presents information about the attributes and methods.

Attributes

Normally, attributes are not thought of as having signatures; methods get all the credit. However, an attribute has a type, and this type is represented in the class diagram. Consider the two attributes that are in the Cabbie example:

-companyName:String
-name:String

Both of these attributes are defined as strings. This is represented by the name of the attribute followed by the type (in these cases, String). There could have been attributes that were defined as int and float as well, as in this example:

-companyNumber:float
-companyAge:int

By looking at the class diagram, you can tell ...

Get Object-Oriented Thought Process, The, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.