-
Notifications
You must be signed in to change notification settings - Fork 0
Synchronous creation
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.
Copyright 2020, 2021, 2022, 2023, 2025 © Leon Starr under MIT Open Source License
- Why they are problematic
- Instance attribute creation values
- Boolean values
- Special values
- Enumerated values
- Action block
- Statement
- Single line action
- Multiple dependent actions on a single line
- An action spread across multiple lines
- A conditional group of single line actions
- Comments
- Finding instances
- Attribute access
- Creation and deletion
- Subclass migration
- Creating a table from a class
- Creating a table with a definition
- Converting a table into a class
- Set operations on tables
- Set comparisons on tables
- Join
- Rename
- Extend
- Aggregation
- Rank
- Image
- Input values
- Signatures and name doubling
- Output values
- Execution order
- Sequential execution
- Conditional execution
- Signals
- Scrall has no for_each action
- Iteration