Changing the value of an instance
About this task
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
.
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.
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
.
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.