the models are the code - executable uml

20
Executable UML The Models are the Code - Executable UML Lecture 10 – Wrapping things up Paul Krause

Upload: hyacinth-rocha

Post on 03-Jan-2016

17 views

Category:

Documents


1 download

DESCRIPTION

The Models are the Code - Executable UML. Lecture 10 – Wrapping things up Paul Krause. Subject Matter Partitioning. Sally Shlaer and Stephen Mellor established the foundations for this approach in 1988 Object-oriented Systems Analysis - Modelling the World in Data - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: The Models are the Code - Executable UML

Executable UML

The Models are the Code -Executable UML

Lecture 10 – Wrapping things up

Paul Krause

Page 2: The Models are the Code - Executable UML

Executable UML

Subject Matter Partitioning

Sally Shlaer and Stephen Mellor established the foundations for this approach in 1988 Object-oriented Systems Analysis - Modelling the

World in Data

Recognises that a system consists of a set of subject matters - domains Each domain consists of a set of classes Domains are represented as packages in UML

A Domain Chart captures the dependencies between domains

Page 3: The Models are the Code - Executable UML

Executable UML

What is a Domain? 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 Mellor and Balcer, p30

Real Worlds Air traffic control, patient administration, banking,

Hypothetical Worlds 3D geometry, statistical analysis, …

Abstract Worlds User interface, messaging, workflow, …

Page 4: The Models are the Code - Executable UML

Executable UML

Example Domain Chart

Fuel Sales Shopping

ForecourtHardwareInterfacing

Checkout

User Interface LoggingTelecommunications

Interface

Page 5: The Models are the Code - Executable UML

Executable UML

Advantages of Subject Matter Partitioning Reuse

Well-defined interfaces

Effective use of subject-matter knowledge

Stability to changing requirements

Stability to changing technology

Incorporation of third party software

Effective integration with Use-Case driven development

Page 6: The Models are the Code - Executable UML

Executable UML

Use Case DescriptionUse 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

Page 7: The Models are the Code - Executable UML

Executable UML

Domain Level Sequence Diagram

<Boundary>Forecourt Hardware Interfacing User Interface Fuel Sales Checkout

1: binaryInputChanges

2: nozzleRemoved

3:requestPumpEnable

4:alertAttendantToRequestForPumpEnable

5:pumpEnableButtonPressed

6:pumpEnabled

7:GO creation

8:enablePump

9:setBinaryOutput

10:binaryInputChanges

11:triggerDepressed

12:startPumping13: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: …

Page 8: The Models are the Code - Executable UML

Executable UML

Domain Class Diagram - Fuel Sales

Pump

PumpSpecification FillingStation

Nozzle Tank

FuelGrade

Page 9: The Models are the Code - Executable UML

Executable UML

Domain Class Diagram - Fuel Sales

Pump

PumpSpecification FillingStation

Nozzle Tank

FuelGrade

1 isDispensingFuelFor

1..* dispensesFuelAt

isSpecifiedBy 1

specifies 0..*

isInUseAt 0..1

hasInUse 0..1

1 isLocatedAt

1..* isLocationFor

suppliesFuelTo

0..*1

acquiresFuelFrom

1 currentlyStores

0..* isCurrentlyStoredIn

R4 R10

R6 R5

R1

R2

Page 10: The Models are the Code - Executable UML

Executable UML

Domain Class Diagram - Fuel Sales

Pump

PumpSpecification FillingStation

Nozzle Tank

FuelGrade

1 isDispensingFuelFor

1..* dispensesFuelAt

isSpecifiedBy 1

specifies 0..*

isInUseAt 0..1

hasInUse 0..1

1 isLocatedAt

1..* isLocationFor

suppliesFuelTo

0..*1

acquiresFuelFrom

1 currentlyStores

0..* isCurrentlyStoredIn

R4 R10

R6 R5

R1

R2

Delivery

1 wasMadeFrom

0..* wasUsedToMake

Page 11: The Models are the Code - Executable UML

Executable UML

Active vs Passive Classes

Active Classes The behaviour of instances of active classes

(“active objects”) varies over time e.g. Instances of a Thread class can be started,

paused, continued, stopped This behaviour can be captured in a Statechart

Passive Classes Passive objects have the same behaviour at all

times Operations on a class are sufficient to define its

behaviour Information classes, e.g. Address, are typically of

this kind

Page 12: The Models are the Code - Executable UML

Executable UML

Modelling Operations Operations are used to model state-

independent behaviour

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

Operations are executed synchronously the caller waits until the action has been executed

and a result returned before continuing

The resulting action may in turn invoke (synchronously) other actions, or asynchronous behaviour by generating signals

Page 13: The Models are the Code - Executable UML

Executable UML

UML Statecharts

Closed Down

Idle

Entry / displayWelcome

startup closedown

ProcessingCustomer

Input

card inserted / get pin

validation received [invalid card] / confiscate TerminatingTransaction

ProcessingTransaction

withdrawal selected [valid card] / display wait

Page 14: The Models are the Code - Executable UML

Executable UML

Good Practice for Statecharts

Express the behaviour of Active Classes using a Statechart for each active class

Restrict usage to a subset of the full Statechart notation for clarity: Actions are specified on entry into a state (not

on exit, or on the transition itself) An individual event can only cause a single

transition out of a given state

This usage corresponds to expressing behaviour as a “Moore” machine

Page 15: The Models are the Code - Executable UML

Executable UML

Statechart for Delivery Class

Initialised

InProgress

fuelUnitDelivered()fuelUnitDelivered( )

Cancelled

Complete

deliveryComplete()

Page 16: The Models are the Code - Executable UML

Executable UML

Statechart for Delivery Class

Initialised

InProgress

entry/ update volume delivered and cost

fuelUnitDelivered() fuelUnitDelivered( )

Cancelled

Complete

deliveryComplete()

Page 17: The Models are the Code - Executable UML

Executable UML

Statechart for Delivery Class

Initialised

InProgress

entry/ update volume delivered and cost

fuelUnitDelivered() fuelUnitDelivered( )

Cancelled

Complete

deliveryComplete()

Action Language specifiesthe detailed action

that is performed herein terms of the concepts

in the associated domain model

Page 18: The Models are the Code - Executable UML

Executable UML

Interactions within Domains

Operations can be invoked on objects or classes within a Domain.

Signals can be sent to (active) objects or classes within a domain.

Object-level sequence diagrams

Collaboration diagrams

Page 19: The Models are the Code - Executable UML

Executable UML

Interactions with other domains

Domain-level sequence diagrams

Operations can be invoked on other domains

Signals can be sent to other domains

Page 20: The Models are the Code - Executable UML

Executable UML

Next Actions

Final Lab Class Tomorrow

Example Exam papers will put up on the Website tomorrow

If you have any further questions, please e-mail me or come along to office hours 2-4.00pm on Mondays