Skip to content

Instance attribute creation values

Leon Starr edited this page Nov 6, 2023 · 3 revisions

First, consider new instance creation. The UML standard already suggests a solution with the initial value field on the class diagram. This is a value applied by default to the attribute of any new instance. This moves default initial values out of the action language and into the class model. When an instance is created, the model execution architecture will use those initial values if no other value is specified.

For example, if you want to ensure that every instance of Dog has its Dog.Breed attribute initialized with the value “Collie”, just put that value in the appropriate class model’s initial attribute value definition. Then, when you create a new instance of Dog, omit the Breed attribute like so:

new dog .= &R1 *Dog( Name: ^Supplied name )

Here a new instance of Dog is created via the * create instance action and referenced along relationship R1 via the & relate action with the instance references to assigned to the new dog single instance flow.

And the breed will be set automatically to "Collie" since it wasn’t specified. The rightmost part of the action links the newly created Dog to the local instance, presumably Dog Owner, on the R1 association.

Introduction

Model semantics

Flows (as Variables)

Constants and literals

Structure of an activity

Accessing the class model

Data flow


Grammar and parsing notes

Components

Clone this wiki locally