-
Notifications
You must be signed in to change notification settings - Fork 0
Instance deletion
Like creation, deletion can be triggered by a signal or an action. Deletion is easier to specify than creation since you don’t need to worry about initializing any attributes. You just need to be careful not to invalidate any references from other classes.
To delete an instance synchronously, use the delete !* command. Symbolically, you can remember it as “un-create”. Let’s say you have a set of Aircraft instance references:
!* ac
In the example above, all instances in the instance set variable ac are immediately deleted. It is best to use this approach with classes that do not have state models. If the class does have a state model, the modeler should ensure proper synchronization so that deletion occurs when no critical activities are being executed by the instances to be deleted. Furthermore, an error will occur if this action would invalidate any references from other classes.
As with most operations on an instance set variable, there is no special consequence or error in the case of an empty set.
You can also delete multiple instance sets with a single action. This is necessary when two instances are related by an unconditional association or a generalization.
Let's say, for example that you have a generalization R12 such that an Aircraft is either a Helicopter or a Fixed Wing Aircraft. Assuming you have a labeled flow named landed helicopter that you want to delete, you must ensure that both the superclass and the subclass instance is removed in the same action.
Otherwise, you could end up with a superclass instance of Aircraft with no corresponding subclass instance during the time interval when your Activity is executing that could potentially be accessed by some other Action. To delete them with the same Delete Action, do this:
!* landed helicopter, landed helicopter/R12/Aircraft
Deleting with an event is simply a matter of sending a normal event to the instance you want to delete. Presumably that event will cause a state transition to a deletion state in the target class. Since there’s nothing special about a deletion event, there is no special Scrall syntax.
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