Download presentation
Presentation is loading. Please wait.
Published byLesley Holt Modified over 9 years ago
1
Executable UML The Models are the Code - Executable UML Lecture 8 - Interactions and Operations Paul Krause
2
Executable UML Lecture 8 - Interactions and Operations v Domain-level sequence diagrams v Object-level sequence diagrams v Collaboration diagrams v Operations and the Action Specification Language
3
Executable UML Use Case Description Use Case Name Purpose Preconditions Invariants Primary Scenario Postconditions Make Fuel Delivery To allow a paying customer to deliver fuel of a selected grade The desired fuel grade is available Tank level >4% tank capacity while pump is on 1. Customer removes nozzle from holster; 2. Attendant enables pump; 3. Customer selects one fuel grade; 4. Pump motor is started; 5. Customer uses trigger to control fuel delivery; 6. Customer replaces nozzle in holster; 7. Pump motor is stopped. At least 2 litres of fuel have been delivered
4
Executable UML Domain Level Sequence Diagram Forecourt Hardware InterfacingUser InterfaceFuel SalesCheckout 1: binaryInputChanges 2: nozzleRemoved 3:requestPumpEnable 4:alertAttendantToRequestForPumpEnable 5:pumpEnableButtonPressed 6:pumpEnabled 7:GO creation 8:enablePump 9:setBinaryOutput 10:binaryInputChanges 11:triggerDepressed 12:startPumping 13:impellorPulse 14:fuelUnitDelivered 1: Customer removes nozzle 2: 3:Request pump enable 4: Alert attendant of Customer 5: Attendant enables pump 6: 7: Create Transaction Item 8: 9: Pump motor enabled 10: Customer presses trigger 11: 12: Start pumping fuel 13: loop until trigger released 14: Unit of fuel is delivered 15: …
5
Executable UML Object Level Sequence Diagram: > Administrator selectedPatient: Patient availableBed: Bed > Resource Allocation > Location Tracking admitPatient assignBed bedAssigned patientNowInBed requestCaseNotes patientAdmitted Admit In-Patient
6
Executable UML Object collaboration diagram: Admit Patient > Administrator selectedPatient: Patient availableBed: Bed > Resource Allocation > Location Tracking Admit In-Patient
7
Executable UML Object collaboration diagram > Administrator selectedPatient: Patient availableBed: Bed > Resource Allocation > Location Tracking 1: admitPatient5: requestCaseNotes 2: assignBed 3: bedAssigned 4: patientNowInBed 6: patientAdmitted Admit In-Patient
8
Executable UML Object collaboration diagram > Administrator selectedPatient: Patient availableBed: Bed > Resource Allocation > Location Tracking 1: dischargePatient4: returnCaseNotes 2: releaseBed3: bedReleased5: patientDischarged Discharge In-Patient
9
Executable UML Class collaboration diagram > Administrator :Patient :Bed > Resource Allocation > Location Tracking dischargePatientreturnCaseNotes releaseBedbedReleasedpatientDischarged admitPatient requestCaseNotes assignBed bedAssigned patientNowInBed patientAdmitted
10
Executable UML Simple Train Example [Raistrick et al, 2004] Hop 1Hop 2 Acceleration Curve 1 Acceleration Curve 2 Acceleration Curve 3 Acceleration Curve 4 Acceleration Curve 5 Acceleration Curve 6 Speed Distance
11
Executable UML Train Control Domain TrainHopAccelerationCurveJourney is established by 0..1 1 1 has firstis first hop in is currently being negotiated by is currently negotiating is preceded by is followed by is first curve in has firstis currently performing is currently being performed by is followed by is preceded by has established R1 R2 R3 R4 R5 R6 R7
12
Executable UML Class collaboration model :Train :Hop:AccelerationCurve > :Motor negotiateHopperformCurve adjustSpeed hopNegotiatedcurvePerformed finalHopNegotiatedfinalCurvePerformed
13
Executable UML Assigning class responsibilities :Train :Hop:AccelerationCurve > :Motor negotiateHopperformCurve adjustSpeed hopNegotiatedcurvePerformed finalHopNegotiatedfinalCurvePerformed At start of jounrey: 1. link myself to first hop 2. ask hop to “negotiate” itself When each hop is complete: 1.Unlink that Hop from Train 2.Delete the completed Hop 3.Link next Hop (if any) to train When each AccelerationCurve (AC) is complete: 1.Unlink that AC from Hop 2.Delete the completed AC 3.Link the next AC (if any) to Hop
14
Executable UML Policies for the Train Control Domain v Dynamic classes are created “top-down” v Deletion is performed “bottom-up” v Commands are sent “top-down” v Responses are sent “bottom-up” v Unfortunately, it is not always possible to have such simple policies!
15
Executable UML Modelling Operations v Operations are used to model state-independent behaviour v An operation is the invocation of some action via a parameterised interface think of a method call in Java or a function call in C v Operations are executed synchronously the caller waits until the action has been executed and a result returned before continuing v The resulting action may in turn invoke (synchronously) other actions, or asynchronous behaviour by generating signals
16
Executable UML Generic operation rules v Operations are specified with an Action Specification Language (ASL) v Operations: are executed synchronously may have zero or more input parameters may have zero or more output parameters may have input and output parameters of any valid data type
17
Executable UML Types of operation v Object-based defined in a class v Class-based may be underlined in a class definition v Domain-based associated with the domain as a whole v Bridge used to map the service requirements to the service requirements of one or more other domains
18
Executable UML Domain operations Fuel SalesShopping Forecourt Hardware Interfacing Checkout User InterfaceLogging Telecommunications Interface A domain based operation can be invoked by: any class in its domain any bridge operation
19
Executable UML Class and object operations PumpPumpSpecificationFillingStation Nozzle TankFuelGrade A class or object based operation can be invoked by: any class or class instance in its domain any domain based operation associated with its domain any bridge operation if it is declared to be “externally visible”
20
Executable UML Example object operation AccelerationCurve curveID startDistance endDistance desiredStartSpeed desiredEndSpeed pollingTimerID pollingRate pollingRateUnits nextCurveID createAccelerationCurve calculateDesiredSpeed if (distanceAlongHop = thisStartDistance) & \ (this.startSpeed = 0.0) then theTrain = this -> R3 -> R2 desiredSpeed = theTrain.minimumSpeed else lengthOfCurve = this.endDist - this.startDist requiredSpeedDiff = this.endSpeed - this.startSpeed speedGradient = requiredSpeedDiff / lengthOfCurve distanceAlongCurve = distAlongHop - this.startDist deltaSpeed = distanceAlongCurve * speedGradient desiredSpeed = deltaSpeed + this.startSpeed end if calculateDesiredSpeed(distanceAlongHop:Real = 0.0):(desiredSpeed:Real)
21
Executable UML Invoking an object-based operation [theDesiredSpeed] = AC2:calculateDesiredSpeed[hopDistance] on theAccCurve Return parameter(s) Key letter for AccelerationCurve Class Operation number in the class definition class instance handle keyword “on” indicates this operation is object based
22
Executable UML Is ASL another programming language? v ASL does not specify software structure anywhere: no pointers, arrays, lists … v No mechanisms to show persistence manner of invocation manner of distribution of messages how data is stored v All these are the business of the model compilers as they are platform dependent issues
23
Executable UML Summary v Behaviour of active objects is specified with state charts v Signals or events induce transitions in an object’s lifecycle v State-independent behaviour is captured in operations v Sequence and collaboration diagrams summarise the signal events and operation calls between objects as they work together to achieve some goal
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.