Skip to content

Synchronous creation

Leon Starr edited this page Aug 9, 2025 · 3 revisions

Creating an instance synchronously (with an action)

The create action creates an instance immediately and returns a reference to the newly created instance. It is synchronous because the creation begins and ends within a single action inside of an activity.

To create a new instance, use the new * symbol with initial values supplied:

ac .= *Aircraft( Tail:t, Altitude:a, Heading:h, Location:l, Airspeed:s)

There are no “not applicable” or “null values” permitted in xUML. So you either create a complete instance or you don’t. This is a necessary consequence of the underlying set theory. It is also a consequence of not assuming anything about the memory implementation.

If an attribute is omitted from the creation action, the attribute’s specified initialization value indicated on the class model will be used. Failing that, a type specific initial value generator operation will be invoked. At least one of these initialization options must be available or a static error will result.

If a class references across an association, all referential attributes must be initialized. Rather than specify the referential attributes directly, each association and associated instance reference must be specified.

The following action is executed by an instance of Owner and provides itself as the necessary instance reference:

v .= *Owned Vehicle( License number:l ) &R1 me

Since you are relating to self, you can shorten it to:

v .= &R1 *Owned Vehicle( License number: l )

And if you don’t need the variable, you can just do this:

&R1 *Owned Vehicle( License number: l )

If we create an instance that holds multiple references, each must be provided in a comma separated list. Here, a Shaft class references both a Cabin and a Bank class.

*Shaft &R4 cab, &R6 mybank

All non-referential attributes are presumably initialized by default values or type initialization values so the parentheses would be empty and may then be omitted.

The comma is necessary since it separates distinct <association>, <instance> pairs. So you read the statement as “Create an instance of Shaft and associate it with the cab instance on R4 and also associate the Shaft instance on R6 with the mybank instance. Without the comma, it would appear that you are linking Shaft to Cabin and then Cabin to Bank which is not the case.

*Shaft &R4 *Cabin, &R6 mybank

Here, a new instance of Cabin is created and provided as an instance reference.

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