Executable UML
The Models are the Code -Executable UML
Lecture 5 - Attributes and Relations
Paul Krause
Executable UML
Lecture 5 - Attributes and Relations
Continue with properties of attributes
Introduction to xUML relationship types
Executable UML
Properties of Attributes
Purpose
Identification role
Dependency on other attributes
Value assignment
Universal meaning
Executable UML
Dependence on other attributes
Rule 1:
The values of all non-identifying attributes depend only on the identifier
Spot Light
Colour temperatureIntensityx Locationy Locationz Location
Change SpotLight ID (Implicit)and the values of any of the other
attributes may change.But the value of any other attribute
may be changed independently of theothers.
Executable UML
Dependence on other attributes
Contact
NameHome addressBirthdateCompany nameWork address
Change the Company nameand the address must (normally)
change
Executable UML
Dependency on other attributes
Contact
NameHome addressBirth date
Company
Name {I}AddressPhoneCafeteria quality
R10..*employs
0..1works at
Executable UML
Dependence on other attributes
Rule 2:
Each non-identifying attribute must depend on the whole ID
Automated Vehicleon Route
Vehicle ID {I}Route ID {I}Accumulated delayEstimated completion timeBattery charge
{These two
attributes depend
on the whole ID
This attribute dependsonly on Vehicle ID
Executable UML
Dependence on other attributes
Automated Vehicleon Route
Vehicle ID {I, R1}Route ID {I}Accumulated delayEstimated completion time
Vehicle
ID {I}WeightBattery chargeTime since last service
R10..1is inservice as
1uses
Executable UML
Value Assignment
Automated Vehicleon Route
Vehicle ID {I, R1}Route ID {I}Accumulated delayEstimated completion time
Executable UML
Value Assignment
Automated Vehicleon Route
Vehicle ID {I, R1}Route ID {I}Accumulated delayEstimated completion time }
The values assigned to thesenon-identifier attributes can bechanged to any other legal value
Executable UML
Value Assignment
Automated Vehicleon Route
Vehicle ID {I, R1}Route ID {I}Accumulated delayEstimated completion time
But we can’t, for example, changethe value of the Route ID (an
identifier attribute) without checkingthat a duplicate instance
is not being created
Executable UML
Value Assignment - Computational dependence
Shaft Encoder
Mark spacingPulse rate
Motor Shaft
\Rotational speedR11
rotational speed isdetected by
1detects
rotationalspeed of
The “\” indicates this attributeis computationally dependent
on other attributes in the model
self.Rotational_speed =my_Shaft_Encoder.Mark_spacing *my_Shaft_Encoder.Pulse_rate
Executable UML
Universal meaning?
Does an attribute always have meaning in a specific class?
If it does not, then again you may need to modify the class model: Never applicable for some instances
then use a generalisation hierarchy and specialise these instances
Not applicable at some momentThen specialise the class into distinct roles
Executable UML
Universal meaning?
Landing Gear
ManufacturerWeight
UninstalledLanding Gear
InstalledLanding Gear
retracted status
R1
Executable UML
Executable UML Relationship Types
Binary Non-reflexiveBinary reflexive
Association ClassGeneralisation
{disjoint, complete}
Executable UML
Lecture 5 - Associations
Naming associations Binary non-reflexive associations
Binary reflexive associations
Association Classes
Loops and constraints
Executable UML
Naming Associations
cardio_7bcardio_7b
cardio_7bcardio_7b
cardio_7b
cardio_1b
def_87c
currently loaded
default
Library ofpresets on
local hard drive
preset files
Executable UML
Application Note
A medical ultra-sound scanner station operates with hundreds of parameter settings.
A complete collection of parameters with initial value settings can be stored in a preset file.
The capabilities of the ultrasound scanner depend entirely on what preset file has been loaded.
Upon power up, the scanner automatically loads values from whichever preset file has been designated as the station default.
Leon Starr - How to Build Class Models
Executable UML
Text Book Solution
Preset File
Name
Station
Serial number {I}
uses
*
• Which preset is currently controlling the station?
• How do we ensure only one preset is controlling the station at a time?
• Which preset file is loaded at power up?
Executable UML
Application rules
At any time, a Station is using the parameter values from one Preset File
Exactly one Preset File is designated as the default for a given station
Any Preset File may be designated as the default for a given Station
Executable UML
Try harder!
Preset File
Name
Station
Serial number {I}
is usingthe values
from
1
suppliesvalues tocontrol
0..1
Executable UML
Default file
Preset File
Name
Station
Serial number {I}
uses valuesby default
from
1
is defaultsource ofvalues for
0..1
Executable UML
The complete solution
Preset File
Name
Station
Serial number {I}is using
the valuesfrom
1
suppliesvalues tocontrol
0..1
uses valuesby default
from
1
is defaultsource ofvalues for
0..1
R1
R2