Executable UML The Models are the Code - Executable UML Lecture 5 - Attributes and Relations Paul Krause
Executable UML Lecture 5 - Attributes and Relations v Continue with properties of attributes v Introduction to xUML relationship types
Executable UML Properties of Attributes v Purpose v Identification role v Dependency on other attributes v Value assignment v Universal meaning
Executable UML Dependence on other attributes Rule 1: v The values of all non-identifying attributes depend only on the identifier Spot Light Colour temperature Intensity x Location y Location z 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 the others.
Executable UML Dependence on other attributes Contact Name Home address Birthdate Company name Work address Change the Company name and the address must (normally) change
Executable UML Dependency on other attributes Contact Name Home address Birth date Company Name {I} Address Phone Cafeteria quality R1 0..* employs 0..1 works at
Executable UML Dependence on other attributes Rule 2: v Each non-identifying attribute must depend on the whole ID Automated Vehicle on Route Vehicle ID {I} Route ID {I} Accumulated delay Estimated completion time Battery charge { These two attributes depend on the whole ID This attribute depends only on Vehicle ID
Executable UML Dependence on other attributes Automated Vehicle on Route Vehicle ID {I, R1} Route ID {I} Accumulated delay Estimated completion time Vehicle ID {I} Weight Battery charge Time since last service R is in service as 1 uses
Executable UML Value Assignment Automated Vehicle on Route Vehicle ID {I, R1} Route ID {I} Accumulated delay Estimated completion time
Executable UML Value Assignment Automated Vehicle on Route Vehicle ID {I, R1} Route ID {I} Accumulated delay Estimated completion time } The values assigned to these non-identifier attributes can be changed to any other legal value
Executable UML Value Assignment Automated Vehicle on Route Vehicle ID {I, R1} Route ID {I} Accumulated delay Estimated completion time But we can’t, for example, change the value of the Route ID (an identifier attribute) without checking that a duplicate instance is not being created
Executable UML Value Assignment - Computational dependence Shaft Encoder Mark spacing Pulse rate Motor Shaft \Rotational speed R1 1 rotational speed is detected by 1 detects rotational speed of The “\” indicates this attribute is 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? v Does an attribute always have meaning in a specific class? v 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 moment Then specialise the class into distinct roles
Executable UML Universal meaning? Landing Gear Manufacturer Weight Uninstalled Landing Gear Installed Landing Gear retracted status R1
Executable UML Executable UML Relationship Types Binary Non-reflexive Binary reflexive Association Class Generalisation {disjoint, complete}
Executable UML Lecture 5 - Associations v Naming associations Binary non-reflexive associations v Binary reflexive associations v Association Classes v Loops and constraints
Executable UML Naming Associations cardio_7b cardio_1bdef_87c currently loaded default Library of presets on local hard drive preset files
Executable UML Application Note v A medical ultra-sound scanner station operates with hundreds of parameter settings. v A complete collection of parameters with initial value settings can be stored in a preset file. v The capabilities of the ultrasound scanner depend entirely on what preset file has been loaded. v 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 v At any time, a Station is using the parameter values from one Preset File v Exactly one Preset File is designated as the default for a given station v 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 using the values from 1 supplies values to control 0..1
Executable UML Default file Preset File Name Station Serial number {I} uses values by default from 1 is default source of values for 0..1
Executable UML The complete solution Preset File Name Station Serial number {I} is using the values from 1 supplies values to control 0..1 uses values by default from 1 is default source of values for 0..1 R1 R2