Presentation is loading. Please wait.

Presentation is loading. Please wait.

Executable UML The Models are the Code - Executable UML Lecture 4 - How to Build Class Models Paul Krause.

Similar presentations


Presentation on theme: "Executable UML The Models are the Code - Executable UML Lecture 4 - How to Build Class Models Paul Krause."— Presentation transcript:

1 Executable UML The Models are the Code - Executable UML Lecture 4 - How to Build Class Models Paul Krause

2 Executable UML Lecture 4 - How to Build Class Models v Specifications vs Things v Interactions v Roles  working within our modelling goals v Attributes

3 Executable UML Specification Classes Aircraft Specification Model number {I} Stall profile Weight Wingspan Fuel consumption Aircraft Registration number {I} Maintenance status Assigned pilot Assigned mechanic Hours flown 1 design is specified by 0..* specifies design of R1 Abstract Properties common to a specific aircraft type Concrete Properties common to a specific aircraft instance Distinct lifecycles and properties

4 Executable UML Specification Pattern Widget Specification Model number {I} Widget Serial number {I} 1 design is specified by 0..* specifies design of R1 AbstractConcrete design characteristics, references to sub-specifications or other related specifications characteristics that vary from widget to widget, even when the widgets are defined by the same widget specification Will rarely need a state model to define its behaviour Will normally need a state model to define its behaviour

5 Executable UML Interaction Classes Passenger Name Phone number Flight Number {I} Airline {I} Departure date Departure time Departure airport Arrival date Arrival time Arrival airport 0..* is reserved for 0..* reserves R1 Seat Assignment ??

6 Executable UML Interaction Classes Passenger Name Phone number Flight Number {I} Airline {I} Departure date Departure time Departure airport Arrival date Arrival time Arrival airport 0..* is reserved for 0..* reserves R1 Reservation Ticket number {I} Airline {I, R1} Cost Class Seat assignment

7 Executable UML Role Classes WaferInspection Station 0..* contains 0..1 is loaded into R1 Wafer in Process Allignment Temperature Percent scan complete 0..1 directs scanning of 0..1 is scanned according to R2 Inspection Script Area to cover Scan method Delete once Wafer has been unloaded from the Inspection Station

8 Executable UML Relative Roles Front SideBack Side APPLICATION NOTE: The flat shape can rotate in 3D space and must have exactly one bitmap image on each of its two sides

9 Executable UML Multiplicity v Remember, an important characteristic of an association is the number of instances (objects) that participate in each instance of the domain relationship v UML allows specific numbers in a multiplicity relation v In xUML the recommendation is to only use four kinds:  unconditional;1, or 1..*  conditional;0..1, or 0..*

10 Executable UML Relative Roles Flat ShapeSide 1 can be shown by 1..* can show R1 Colour Texture The arguments for making this multiplicity “2” seem compelling, but can we work within our modelling guidelines?

11 Executable UML Two 1:1 associations? Flat Shape Side 1 is front of 1 has front R1 Colour Texture 1 is back of 1 has back R2 But a Side is either the Front or the Back of a Flat Shape, not both!

12 Executable UML Two 1:1 associations? Flat Shape Side 1 is front of 1 has front R1 Colour Texture 1 is back of 1 has back R2 But a Side is either the Front or the Back of a Flat Shape, not both!

13 Executable UML Two conditional associations? Flat Shape Side 0..1 is front of 1 has front R1 Colour Texture 0..1 is back of 1 has back R2 But this says that a Side might exist that does not belong to any Flat Shape!

14 Executable UML Two conditional associations? Flat Shape Side 0..1 is front of 1 has front R1 Colour Texture 0..1 is back of 1 has back R2 But this says that a Side might exist that does not belong to any Flat Shape!

15 Executable UML How about making the Sides attributes? Flat Shape Front colour Front texture Back colour Back texture Bitmap Image ? But we need to model the association between a Bitmap Image and a specific Side!

16 Executable UML Solution: Abstract Positional roles as Classes Side Colour Texture 0..* is drawn on 1 has drawn R1 Bitmap Image Front SideBack Side R4 Flat Shape has on front 1 is front of 1 has on back 1 is back of 1 R2R3 N.B. We have worked within our modelling goals and produced a better model!

17 Executable UML What is an Attribute? “A quality or characteristic inherent in or ascribed to someone or something” The American Heritage Dictionary of the English Language Star SAO Number {I} Name Diameter Mass Distance 252838 Alpha Centauri 1.26 M km 1.1 x Sun 4.3 ly 131881 Sirius 4.9 M km 3 x Sun 8.7 ly Two instances of Star Attributes: Prototypical characteristics Attribute Values: Characteristics of a specific instance

18 Executable UML Properties of Attributes v Purpose v Identification role v Dependency on other attributes v Value assignment v Universal meaning

19 Executable UML Purpose v Here the attribute either names or describes a class instance v Descriptive attributes  Size, Capacity, Colour, Stall speed v Naming attributes  Discovered names - Company name, Floor number, Driver’s licence number  Invented names - Pump ID, Transaction ID, Event ID  Using “ID” as a suffix makes it clear these names are the invention of an analyst

20 Executable UML Identification role v Every instance of a class is unique v Consequently, each object must have an attribute whose value can unambiguously identify that object v If an attribute is marked as an identifier, then it is constrained to have distinct values for each instance v In xUML there are three kinds of identifier  implicit identifiers  single-attribute identifiers  compound identifiers

21 Executable UML Implicit identifier location = right zoom = 2 location = centre zoom = 1 location = left zoom = 1.5 IDLocationZoom CAM_1right2 CAM_2centre1 CAM_3left1.5 Camera ID {I} Location Zoom

22 Executable UML Implicit identifier location = right zoom = 2 location = centre zoom = 1 location = left zoom = 1.5 IDLocationZoom CAM_1right2 CAM_2centre1 CAM_3left1.5 Camera ID {I} Location Zoom But this identifier is not adding anything to the model other than guaranteeing uniqueness

23 Executable UML Implicit identifier location = right zoom = 2 location = centre zoom = 1 location = left zoom = 1.5 LocationZoom right2 centre1 left1.5 Camera Location Zoom We can rely on an implicit identifier in this case to guarantee uniqueness

24 Executable UML Implicit vs. Explicit Identifiers v In the preceding example we were only interested in the service each camera performed in a studio  We don’t actually care which precise physical camera maps onto the class instances so long as the attribute values are correct v But sometimes we may need to model a real- world identification scheme  SAO Number, Aircraft registration, Flight number v In these cases we use an explicit identifier  may consist of single or multiple attributes

25 Executable UML Single explicit identifier Star SAO Number {I} Name Diameter Mass Distance 252838 Alpha Centauri 1.26 M km 1.1 x Sun 4.3 ly 131881 Sirius 4.9 M km 3 x Sun 8.7 ly Two instances of Star In contrast to implicit identifiers, typically the values of explicit identifiers will not be assigned by the model compiler

26 Executable UML Compound identifiers StateLicense Number ColourYearMakeModel CA12345pink1960CadillacEldorado CA65432purple1964ACCobra CO12345orange1972VWBeetle Licensed Vehicle State {I} License number {I} Colour Make Model These two attributes together mark a single identifier (State + License number)

27 Executable UML Referential attributes DirectionSideLengthGrade 13Single5000 ftGravel 27Left7000 ftPaved 27Right7000 ftPaved Runway Direction {I} Side {I} Length Grade But we could have two runways with the same value for (Direction + Side) at different airports

28 Executable UML Referential attributes Runway Direction {I} Side {I} Airport {I, R1} Length Grade Airport Code {I} Current visibility 1 is located at 1..* is location of R1 Refers to identifier of the associated Airport class (the renaming is legal)

29 Executable UML Summary v We have illustrated some good practice in developing class models and their associated attributes v Next time we will look at the remaining properties of attributes:  Dependency on other attributes  Value assignment  Universal meaning  Origin v Read Chapter 5 of Mellor and Balcer  also Chapters 1 & 2 of Starr


Download ppt "Executable UML The Models are the Code - Executable UML Lecture 4 - How to Build Class Models Paul Krause."

Similar presentations


Ads by Google