The Models are the Code Executable UML Lecture
The Models are the Code Executable UML Lecture 10 – Wrapping things up Paul Krause Executable UML
Subject Matter Partitioning v Sally Shlaer and Stephen Mellor established the foundations for this approach in 1988 v Object-oriented in Data Systems Analysis - Modelling the World v Recognises that a system consists of a set of subject matters - domains v Each domain consists of a set of classes v Domains are represented as packages in UML v A Domain Chart captures the dependencies between domains Executable UML
What is a Domain? v A domain is an autonomous, real, hypothetical or abstract world inhabited by a set of conceptual entities that behave according to characteristic rules and policies v Mellor and Balcer, p 30 v Real Worlds v Air traffic control, patient administration, banking, … v Hypothetical Worlds v 3 D geometry, statistical analysis, … v Abstract Worlds v User interface, messaging, workflow, … Executable UML
Example Domain Chart Fuel Sales Shopping Checkout Forecourt Hardware Interfacing Executable UML User Interface Logging Telecommunications Interface
Advantages of Subject Matter Partitioning v Reuse v Well-defined interfaces v Effective use of subject-matter knowledge v Stability to changing requirements v Stability to changing technology v Incorporation of third party software v Effective integration with Use-Case driven development Executable UML
Use Case Description Use Case Name Make Fuel Delivery Purpose To allow a paying customer to deliver fuel of a selected grade Preconditions The desired fuel grade is available Invariants Tank level >4% tank capacity while pump is on Primary Scenario 1. 2. 3. 4. 5. 6. Postconditions Executable UML 7. At Customer removes nozzle from holster; Attendant enables pump; Customer selects one fuel grade; Pump motor is started; Customer uses trigger to control fuel delivery; Customer replaces nozzle in holster; Pump motor is stopped. least 2 litres of fuel have been delivered
Domain Level Sequence Diagram Forecourt Hardware Interfacing User Interface Fuel Sales Checkout <Boundary> 1: binary. Input. Changes 1: Customer removes nozzle 2: nozzle. Removed 2: 3: request. Pump. Enable 3: Request pump enable 4: alert. Attendant. To. Request. For. Pump. Enable 4: Alert attendant of Customer 5: pump. Enable. Button. Pressed 5: Attendant enables pump 6: pump. Enabled 6: 7: GO creation 7: Create Transaction Item 8: 9: Pump motor enabled 10: Customer presses trigger 8: enable. Pump 9: set. Binary. Output 10: binary. Input. Changes 11: trigger. Depressed 11: 12: Start pumping fuel 13: loop until trigger released 14: Unit of fuel is delivered 15: … Executable UML 12: start. Pumping 13: impellor. Pulse 14: fuel. Unit. Delivered
Domain Class Diagram - Fuel Sales Pump. Specification Executable UML Filling. Station Pump Fuel. Grade Nozzle Tank
Domain Class Diagram - Fuel Sales Pump. Specification Filling. Station is. Specified. By 1 1 is. Dispensing. Fuel. For R 4 specifies R 10 0. . * 1. . * dispenses. Fuel. At Pump is. In. Use. At 0. . 1 R 6 has. In. Use 0. . 1 1 is. Located. At 1 currently. Stores R 5 R 2 1. . * is. Location. For 0. . * is. Currently. Stored. In Nozzle Executable UML Fuel. Grade supplies. Fuel. To R 1 1 0. . * acquires. Fuel. From Tank
Domain Class Diagram - Fuel Sales Pump. Specification Filling. Station is. Specified. By 1 1 is. Dispensing. Fuel. For R 4 specifies R 10 0. . * 1. . * dispenses. Fuel. At Pump is. In. Use. At 0. . 1 R 6 has. In. Use 0. . 1 Fuel. Grade 1 is. Located. At R 5 R 2 1. . * is. Location. For 0. . * is. Currently. Stored. In Nozzle supplies. Fuel. To R 1 1 0. . * acquires. Fuel. From 1 was. Made. From 0. . * was. Used. To. Make Delivery Executable UML 1 currently. Stores Tank
Active vs Passive Classes v Active Classes v The behaviour of instances of active classes (“active objects”) varies over time v e. g. Instances of a Thread class can be started, paused, continued, stopped v This behaviour can be captured in a Statechart v Passive Classes v Passive objects have the same behaviour at all times v Operations on a class are sufficient to define its behaviour v Information classes, e. g. Address, are typically of this kind 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 v think of a method call in Java or a function call in C v Operations are executed synchronously v 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 Executable UML
UML Statecharts Closed Down startup card inserted / get pin closedown Idle Entry / display Welcome Processing Customer Input validation received [invalid card] / confiscate withdrawal selected [valid card] / display wait Executable UML Processing Transaction Terminating Transaction
Good Practice for Statecharts v Express the behaviour of Active Classes using a Statechart for each active class v Restrict usage to a subset of the full Statechart notation for clarity: v Actions are specified on entry into a state (not on exit, or on the transition itself) v An individual event can only cause a single transition out of a given state v This usage corresponds to expressing behaviour as a “Moore” machine Executable UML
Statechart for Delivery Class Executable UML
Statechart for Delivery Class Executable UML
Statechart for Delivery Class Action Language specifies the detailed action that is performed here in terms of the concepts in the associated domain model Executable UML
Interactions within Domains v Operations can be invoked on objects or classes within a Domain. v Signals can be sent to (active) objects or classes within a domain. v Object-level sequence diagrams v Collaboration diagrams Executable UML
Interactions with other domains v Domain-level sequence diagrams v Operations can be invoked on other domains v Signals can be sent to other domains Executable UML
Next Actions v Final Lab Class Tomorrow v Example Exam papers will put up on the Website tomorrow v If you have any further questions, please e-mail me or come along to office hours 2 -4. 00 pm on Mondays Executable UML
- Slides: 20