OOPortal OOPortal

Logical View  «Prev  Next»
Lesson 3 Modeling attributes
Objective Define the Notation for specifying Model Attributes

Notation for specifying Model Attributes


An attribute describes a piece of information that an object owns or knows about itself. To use that information we must assign a label and a name, and then specify the kind of information, or data type. Data types may be primitive data types supplied by a language or abstract data types defined by the developer. In addition, each attribute may have rules constraining the values assigned to it.
Often a default value is set when no rule is provided.

Attribute visibility

Each attribute definition must also specify what objects are allowed to see the attribute, that is its "visibility." Visibility is defined as public (+) for elements of a class that are visible to all other classes. Private (-) visibility limits access to the element to within the class itself. For example, only operations of the class have access to a private attribute. In the case of generalizations (inheritance), subclasses must have access to the attributes and operations of the superclass or they cannot be inherited. So generalizations use a protected (#) visibility.
Given these requirements, the following notation is used to define an attribute:

  1. Derived attribute indicator: Optional
  2. Attribute name: Required
  3. Data type: Required
  4. Assignment operator and default value: Optional
  5. Constraints: Optional
  6. Visibility: Required before code generation
  7. Class attribute: Optional
Attribute definitions
Modeling Attribute Dissection
The slash mark is optional and denotes a derived attribute. The dollar sign indicates a class-level element, for example, a single instance of the element shared by all objects of the class.
The constraint notation brackets appear throughout UML diagrams to identify any and all additional information that helps clarify the intent of the modeling element. Place any text required to explain the limitations imposed on the implementation of the modeling element in the constraint brackets.

Attribute definitions

Let's create an example attribute definition for a company name. The field has to handle characters and punctuation marks commonly found in company names, but we are limited to 30 positions. There is a no default value, but we want valid display data, so we must initialize the field to spaces.

  1. Create an attribute name
  2. Define the data type
  3. Define the default value
  4. Set the constraints on the data values. First identify the field length.
  5. Next identify the types of data that can be used in the field
  6. 1 to 30 characters, including alphabetic, spaces, and punctuation characters, no special characters allowed

Create Attribute Name
In the next lesson, you will learn about operations.

Modeling Attribute Notations - Quiz

Click the quiz link below to take a short multiple-choice quiz on modeling attributes.
Modeling Attribute Notations - Quiz