Changing the value of an instance

You can specify the value of attributes for instances. An attribute value is the value assigned to an attribute during run time. This functionality enables you to describe a possible setup of objects and parts at a certain point in their lifecycle, you can see a "snapshot" of the system, including the instances that exist and their values. To support this functionality, the Features window for instances includes a column called Value.

About this task

Note:

Initial values are features of the attributes of the class, whereas instance values characterize the specific instance of the class (that object).

An important distinction between the initial value field and the value field in the Features window is that the initial value provided is included in code generation. For all instances of a class, attributes will be assigned the initial value that was specified for them at the class level. However, the value specified for an attribute of an instance is not included in code generation. The value field is provided for modeling purposes only - to provide a snapshot of the attribute at a given point in time.

For example, consider the class, Date, and an object of Date called newYear2004. The class Date has the attributes Day, Month, and Year. The following example shows the initial values for the class Date.

Features window for the Date class, Attributes tab showing initial values

The following example shows the attributes for object newYear2004 of class Date. The Show Inherited check box specifies whether to display the inherited attributes so you can easily modify them.

Features window for the Date class, Attributes tab with Show Inherited check box selected

Click the Specification View button to view the attributes and operations of an object in the object model diagram. The following object model diagram shows the class, Date, and the object of Date called newYear2004.

Object model diagram

In the object model diagram, the object values are displayed using the following format:


[visibility]<attribute name>:<attribute type>=<value>

Note the following information:

  • Instance values are always displayed. To hide the entire attribute, right-click the object and select Display Options.
  • Both the instance and the class must be "available" in the model.