object oriented analysis, design and development using...

17
Lecture 7 UML Worked Example

Upload: duongthuy

Post on 31-Mar-2018

222 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Object Oriented analysis, design and development using UMLcm1947/modules/cp2089/LargeSlidesPDF/Lecture… · Finding classes – step 1 The city of Coruscant has an underground shuttle

Lecture 7

UML Worked Example

Page 2: Object Oriented analysis, design and development using UMLcm1947/modules/cp2089/LargeSlidesPDF/Lecture… · Finding classes – step 1 The city of Coruscant has an underground shuttle

SpecificationThe city of Coruscant has an underground shuttle system that runs between the Spaceport, the Jedi Council Room, the Senate Chamber and the Restaurant complex. Citizens may summon the shuttle at any of the stations by pressing a button. Travellers on the shuttle can press a button to indicate their required destination station. The shuttle only stops at stations to which it has been directed. When there are no travellers it remains at the last station it arrived at, unless there are no passengers for over 2 minutes, in which case it returns to the Spaceport.

Page 3: Object Oriented analysis, design and development using UMLcm1947/modules/cp2089/LargeSlidesPDF/Lecture… · Finding classes – step 1 The city of Coruscant has an underground shuttle

Use Case Diagram

Call shuttle

Choose destination

Citizen

Traveller

Page 4: Object Oriented analysis, design and development using UMLcm1947/modules/cp2089/LargeSlidesPDF/Lecture… · Finding classes – step 1 The city of Coruscant has an underground shuttle

Use Case Diagram – more?

Call shuttle

Choose destination

Citizen

Traveller

ShuttleMove to station

extends

extends

Page 5: Object Oriented analysis, design and development using UMLcm1947/modules/cp2089/LargeSlidesPDF/Lecture… · Finding classes – step 1 The city of Coruscant has an underground shuttle

Finding classes – step 1The city of Coruscant has an underground shuttle system that runs between the Spaceport, the Jedi Council Room, the Senate Chamber and the Restaurant complex. Citizens may summon the shuttle at any of the stations by pressing a button. Travellers on the shuttle can press a button to indicate their required destination station. The shuttle only stops at stations to which it has been directed. When there are no travellers it remains at the last station it arrived at, unless there are no passengers for over 2 minutes, in which case it returns to the Spaceport.

Page 6: Object Oriented analysis, design and development using UMLcm1947/modules/cp2089/LargeSlidesPDF/Lecture… · Finding classes – step 1 The city of Coruscant has an underground shuttle

city of Coruscant underground shuttle system Spaceport Jedi Council Room, Senate Chamber Restaurant complex. Citizens shuttle stations button. Travellers shuttle button destination station. shuttle stations travellers station passengers minutes, Spaceport.

Page 7: Object Oriented analysis, design and development using UMLcm1947/modules/cp2089/LargeSlidesPDF/Lecture… · Finding classes – step 1 The city of Coruscant has an underground shuttle

Finding classes – step 2Group together related or associated nounsDecide if they make

one class, an attribute of another class

Page 8: Object Oriented analysis, design and development using UMLcm1947/modules/cp2089/LargeSlidesPDF/Lecture… · Finding classes – step 1 The city of Coruscant has an underground shuttle

Candidate classesTraveller

But this is an actor – outside the systemStation

Does this do anything?Shuttle

Main problem!Button

Only form of interface?

Page 9: Object Oriented analysis, design and development using UMLcm1947/modules/cp2089/LargeSlidesPDF/Lecture… · Finding classes – step 1 The city of Coruscant has an underground shuttle

Class diagram

ShuttleCurrent posDestinationMinutes

Stop()Move()

ButtonPressed

Press()

station

Page 10: Object Oriented analysis, design and development using UMLcm1947/modules/cp2089/LargeSlidesPDF/Lecture… · Finding classes – step 1 The city of Coruscant has an underground shuttle

Write Use Case examplesJabba the Hutt, at the Restaurant Complex calls the shuttleLuke, who is on the shuttle, wants to go to the Senate Chamber

Page 11: Object Oriented analysis, design and development using UMLcm1947/modules/cp2089/LargeSlidesPDF/Lecture… · Finding classes – step 1 The city of Coruscant has an underground shuttle

Sequence diagram (1) <<Jabba>>

:passenger

:Button :Shuttle :Controllersummon shuttle

stationstation

Destination addedCall acceptedCall accepted

Move to destination

Arrived at destinationArrive

dShuttle arrives

Page 12: Object Oriented analysis, design and development using UMLcm1947/modules/cp2089/LargeSlidesPDF/Lecture… · Finding classes – step 1 The city of Coruscant has an underground shuttle

Sequence diagram (2):Button :Shuttle :Controller

Choose destinationstation

station

Destination addedCall acceptedCall accepted

<<Luke>>:passenger

Move to destination

Arrived at destinationArrive

dShuttle arrives

Page 13: Object Oriented analysis, design and development using UMLcm1947/modules/cp2089/LargeSlidesPDF/Lecture… · Finding classes – step 1 The city of Coruscant has an underground shuttle

From the sequence diagramUpdate your class diagram

Button looks like it might be more than just a buttonShuttle needs to have some sort of data controller to store destinations

From each sequenceFor each relevant class• Produce a State transition diagram

Page 14: Object Oriented analysis, design and development using UMLcm1947/modules/cp2089/LargeSlidesPDF/Lecture… · Finding classes – step 1 The city of Coruscant has an underground shuttle

Shuttle STD – from seq.diag 1

At stationCreating

new destination

Moving to destination

Receive station/destination

Destination confirmedArrive at

destination

Page 15: Object Oriented analysis, design and development using UMLcm1947/modules/cp2089/LargeSlidesPDF/Lecture… · Finding classes – step 1 The city of Coruscant has an underground shuttle

Shuttle STD – from seq.diag 1

At stationCreating

new destination

Moving to destination

Receive station/destination

Destination confirmedArrive at

destination

Page 16: Object Oriented analysis, design and development using UMLcm1947/modules/cp2089/LargeSlidesPDF/Lecture… · Finding classes – step 1 The city of Coruscant has an underground shuttle

Design and CodingButton

May be more complex than just a buttonProgrammer needs to develop usable interface• Information user wants• Constraints of the language/hardware

Page 17: Object Oriented analysis, design and development using UMLcm1947/modules/cp2089/LargeSlidesPDF/Lecture… · Finding classes – step 1 The city of Coruscant has an underground shuttle

Design & codingShuttle

Needs a data storage to hold the destination(s)Has other functionality• E.g. Returns to base after 2 mins

– Requires a timer

• May need to “optimise” movement– Work out which is the next destination