230 likes | 237 Views
The Models are the Code - Executable UML. Lecture 5 - Attributes and Relations Paul Krause. Lecture 5 - Attributes and Relations. Continue with properties of attributes Introduction to xUML relationship types. Properties of Attributes. Purpose Identification role
E N D
The Models are the Code -Executable UML Lecture 5 - Attributes and Relations Paul Krause
Lecture 5 - Attributes and Relations • Continue with properties of attributes • Introduction to xUML relationship types
Properties of Attributes • Purpose • Identification role • Dependency on other attributes • Value assignment • Universal meaning
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. Spot Light Dependence on other attributes Rule 1: • The values of all non-identifying attributes depend only on the identifier
Name Home address Birthdate Company name Work address Change the Company name and the address must (normally) change Contact Dependence on other attributes
Name Home address Birth date Name {I} Address Phone Cafeteria quality R1 0..* employs 0..1 works at Company Contact Dependency on other attributes
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 Automated Vehicle on Route Dependence on other attributes Rule 2: • Each non-identifying attribute must depend on the whole ID {
Vehicle ID {I, R1} Route ID {I} Accumulated delay Estimated completion time ID {I} Weight Battery charge Time since last service Automated Vehicle on Route Vehicle Dependence on other attributes R1 1 uses 0..1 is in service as
Vehicle ID {I, R1} Route ID {I} Accumulated delay Estimated completion time Automated Vehicle on Route Value Assignment
Vehicle ID {I, R1} Route ID {I} Accumulated delay Estimated completion time Automated Vehicle on Route Value Assignment The values assigned to these non-identifier attributes can be changed to any other legal value }
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 Automated Vehicle on Route Value Assignment
Mark spacing Pulse rate \Rotational speed The “\” indicates this attribute is computationally dependent on other attributes in the model Shaft Encoder Motor Shaft Value Assignment - Computational dependence R1 1 rotational speed is detected by 1 detects rotational speed of self.Rotational_speed = my_Shaft_Encoder.Mark_spacing * my_Shaft_Encoder.Pulse_rate
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 moment • Then specialise the class into distinct roles
Manufacturer Weight retracted status Uninstalled Landing Gear Installed Landing Gear Landing Gear Universal meaning? R1
Binary reflexive Binary Non-reflexive Association Class Generalisation {disjoint, complete} Executable UML Relationship Types
Lecture 5 - Associations • Naming associations • Binary non-reflexive associations • Binary reflexive associations • Association Classes • Loops and constraints
cardio_7b cardio_7b cardio_7b cardio_7b cardio_7b cardio_1b def_87c Naming Associations preset files currently loaded default Library of presets on local hard drive
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
Serial number {I} Station Text Book Solution Preset File * Name 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?
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
Serial number {I} Station Try harder! Preset File 0..1 1 Name is using the values from supplies values to control
Serial number {I} Station Default file Preset File 0..1 1 Name uses values by default from is default source of values for
Serial number {I} Station The complete solution R1 0..1 1 Preset File supplies values to control is using the values from Name R2 0..1 1 is default source of values for uses values by default from