lecture 5 uml and modelling behaviour. uml unified modelling language successor to a number of...

24
Lecture 5 UML and Modelling Behaviour

Post on 19-Dec-2015

225 views

Category:

Documents


1 download

TRANSCRIPT

Lecture 5

UML and Modelling Behaviour

UMLUnified Modelling Language

• Successor to a number of Object-Oriented Analysis and Design methods

• the 3 Amigos: Booch, Rumbaugh, Jacobson• the company Rational markets Case tools

(Rose) , Development tools, courses and methods: RUP (Rational Unified Process)

• UML standardised by the OMG• Very widely used

UML Diagrams

• Core Diagrams:– Class Diagram cf ER diagrams– State Diagram cf lifecyle diagrams

• Others have added to describe– Analysis ( Use case, Activity Diagram)– Interaction (Sequence Diagrams)– Delivery ( Package Diagram)

Real World

Machine

Static Dynamic

Class Diagram

Activity Diagram

Use Case Diagram

Sequence Diagram

Collaboration Diagram

State Diagram

Package Diagram

Deployment Diagram

UML Diagrams

Specification

Real World - Specification - Construction

• The development process requires models of different domains of the whole system– models of the real worldreal world - people, documents,

activities, relationships

– models of an ideal system - a specification specification independent of how the system will be construction

– models which explain how the constructed constructed system works

General - Concrete

• General models describe the things that are true for a wide range of objects - for all objects of a given type

• or the common processing for a task

• Concrete models describe a specific collection of specific objects,

• or a specific sequence of events

boatname,pos

hoursTo()

<boat>‘perdika’15N 35W

Static - Dynamic

• Static:– Defines the structure of the software– Class (type) model - shows the classes, their

attributes, methods and relationships– Package model - shows major subsystems

• Dynamic:– Defines the way the software behaves when it

undertakes some activity, or responds to some event

User Interface Forms, Reports

‘Real World’

HTML, Windows

Actors

Stakeholders Flesh and Blood,Paper

objectDB layer Oracle/SQLServer

PL/SQL, J2EE, .NETBusiness RulesMiddleware

Member Functions

• read– hoursTo(pos: Latlong) : Real

• update– moveTo(newpos: Latlong) : Latlong

• position := newpos;

– to make this change persistant:• select value(b) into cur from boats b where name=‘perdika’;• cur.moveto(newpos);• update boats b set row=cur where name=‘perdika’;

object

Use Case : report boat position

report boatposition

radio operator

net controller

Use Case description

• During the role call each morning, the net controller will call each boat in turn. When the boat’s radio operator hears the name, she will reply and once connection has been established, the operator will report the boat’s current position and speed. The net controller records the new position.

Concrete Scenario

• The net controller on the morning of 18 May 2002 calls for ‘Perdika’. The skipper replies and reports the position as 23N 15E. The net controller enters this position but the system detects that this is too far from yesterdays position of 22N 14W. The net controller reports this error. ‘Perdika’ is not able to receive, but another operator reports that Perdika’s skipper doesn’t know his E from his W, and the net controller records 23N 15W which is accepted.

Sequence Diagram (concrete)

calling ‘Perdika’

hello net

position please

23N 15W

radio op. net controller system

move(Perdika,23N15W)

ok

thanks Perdika

Sequence Diagram

calling <name>

hello net

position please

<pos>

radio op. net controller system

move(<name>,<pos>)

ok

thanks <name>

Sequence Diagram - detailed

calling <name>

hello net

position please

<pos>

radio op. net controller GUI boats

table

move(<name> ,<pos>)

ok

thanks <name>

a Boat

moveTo(<pos>)

Server

get boat(<name>)

put boat(<name>)

DB

Handling Errors• Much of the complexity of a system lies in handling all the

things which can go wrong with a basic use case:– RW problems:

• no reply from boat

• only part of the position heard

• position invalid w.r.t. previous position in database

– Interface:• controller enters name incorrectly

– Machine problems - (failures)• database out of date (bad restore)

• lost connection with server

Sequence Diagram (concrete)

calling Perdika

hello net

position please

23N 15E

radio op. net controller system

move(perdika,23N,15E)

error(out of range)are you sure? repeat

23N 15Wmove(perdika,23N,15W)

okthanks Perdika

Sequence Diagram - outofrange error

calling <name>

roger

position please

<pos>

radio op. net controller system

move(<name>,<pos>)

outofRange(pos,oldpos)error - repeat

<pos>

move(<name>,<pos>)

ok

Generalised process• Need to define a single process to handle

– the normal error-free case• boat name found, pos ok,

– the normal errors • boat name not found, pos ok, pos invalid, pos outofrange

– the exceptional errors • lost server connection, db error..

• General case involves multiple sequences– choice - selection of paths

– iteration - repeated paths

– exceptions - quit main sequence

Activity Diagram

• Like a flow chart - describes an activity with multiple stages of processing

• Shows choice, iteration

• Allows parallel sub activities

Morning call process

get name find name

call nameno more

report pos

input pos validate pos

report/request

update pos

boat systemnet controller

error

State Diagram

• Describes what happens to an object throughout its life cycle from creation to deletion.

• ‘Long Running Transaction’

• Entity Life History

unknown pos

new(name)

safe

at riskmoveto()

[no report for two days]

moveto(pos)

moveto()

moveto(pos)

moveto(pos)

drop

Work to do

• Tutorial - behaviour modelling– Mayday: boat reports trouble, net controller finds nearest

boat and asks it to go to the aid of the boat in trouble– Emp-Dept:

• employee moves department

• manager approves salary increase for emp to top of salary grade

• Next week– Common tasks - matching – Patterns in design and analysis