Download presentation
Presentation is loading. Please wait.
Published byShannon Parrish Modified over 9 years ago
1
CS12420 Sequence Diagrams – a UML notation for modelling bahaviour Lynda Thomas ltt@aber.ac.uk Images from Wikipedia unless credited or mine
2
Current UML - recap Class diagrams tell you: –the static structure of the system –the relationships between the data –the methods give clues to what can happen Object diagrams tell you: –A snapshot of how the system might look at some point in time
3
Class Diagram Object Diagram
4
How do you model what happens in a software system? Use Case diagram tells you: –Who the actors are in the system –What they can do This is really an analysis diagram
5
But that doesn’t tell you design i.e. in what order things happen or how to write the methods
6
Sequence diagrams do that Let’s use google http://en.wikipedia.org/wiki/Sequence_diagrams http://www.ibm.com/developerworks/rational/libr ary/3101.htmlhttp://www.ibm.com/developerworks/rational/libr ary/3101.html http://www.agilemodeling.com/artifacts/sequence Diagram.htmhttp://www.agilemodeling.com/artifacts/sequence Diagram.htm
7
TIMETIME
8
So the basic idea is that it shows ‘what happens when’ Phone Example is ‘above’ the specific design level of a program – more like analysis Sequence Diagrams can be at any level actually – analysis or design and help you ‘get your head around’ what is happening Consider the procedure for applying to university through UCAS – let’s try it
9
But usually used to look at how objects in an OO system interact Let’s have a look at the.pdf file http://csis.pace.edu/~marchese/CS389/L9 /Sequence%20Diagram%20Tutorial.pdf for the syntax http://csis.pace.edu/~marchese/CS389/L9 /Sequence%20Diagram%20Tutorial.pdf
10
Cute (but just noticed error) - Three Little Pigs http://www.tracemodeler.com/articles/pimp-my-diagram-three-little-pigs/index.html?src=rss
11
Why not just code it? Sequence diagrams describe single use cases showing the behaviour across objects of many classes can see many objects/classes at a time on same page good sequence diagram is still a bit above the level of the real code can be implemented in many different languages non-coders can do sequence diagrams easier to do sequence diagrams as a team
12
An example CS122 exam: The translation unit. Ordinary users of the unit can look up Welsh and English words and phrases and get their translation. They can also submit documents for translation (in the direction Welsh to English or English to Welsh) and find out whether those translations are complete, in process or not started……. Let’s add a new functional requirement: Users can submit and get an emergency translation of a document
13
0..* -dictionary 0..* -myDocs 0..1 -trans Application //runs menu +emerTrans (): void LinguisticUnit //a word or phrase DocumentInfo//information about document +DocumentInfo(String docName, String whichDirection, String uid, Date dateSubmitted) + String getDocName() + void setCheckedOut(Translator translator) +Translator getTranslator() + void setCompleted() + boolean isCompleted() + Date getDate() + String toString() Translator //stores all info -String uid -String phone Model //holds data 1..1 0..* -translators 0..* -allDocs +doEmerTrans (): void
15
0..* -dictionary 0..* -myDocs 0..1 -trans Application //runs menu +emerTrans (): void LinguisticUnit //a word or phrase DocumentInfo//information about document +DocumentInfo(String docName, String whichDirection, String uid, Date dateSubmitted) + String getDocName() + void setCheckedOut(Translator translator) +Translator getTranslator() + void setCompleted() + boolean isCompleted() + Date getDate() + String toString() Translator //stores all info -String uid -String phone Model //holds data 1..1 0..* -translators 0..* -allDocs +getFreeTrans (): Translator +doEmerTrans (): void
16
aTrans=
17
0..* -dictionary 0..* -myDocs 0..1 -trans Application //runs menu +emerTrans (): void LinguisticUnit //a word or phrase DocumentInfo//information about document +DocumentInfo(String docName, String whichDirection, String uid, Date dateSubmitted) + String getDocName() + void setCheckedOut(Translator translator) +Translator getTranslator() + void setCompleted() + boolean isCompleted() + Date getDate() + String toString() Translator //stores all info -String uid -String phone Model //holds data 1..1 0..* -translators 0..* -allDocs +getFreeTrans (): Translator +doEmerTrans (): void +doEmer(DocInfo d): void
19
Alternatives? Interaction diagrams do the same sort of job Take an object diagram and draw numbered arrows I think they are harder to understand but easier to write
20
Detailed: Initialize total to zero Initialize counter to zero Input the first grade while user has not as yet entered the sentinel add this grade into the running total add one to the grade counter input the next grade (possibly the sentinel) if the counter is not equal to zero set the average to total /counter print the average else print 'no grades were entered' Pseudocode can be used at any level (code w/out syntax) Higher Level: (doEmerTrans() of Model) aDoc=new DocInfo(…) aTrans= freetranslator() checkout aDoc to aTrans aDoc.setCompleted() That tells me that I need to look further at freetranslator() (easy) and at checkout() … Decide to use setCheckedout(aTrans) in DocInfo … here is pseudocode translator=aTrans translator.doEmer() Now need to elaborate doEmer() in Translator
21
Here is a vending machine State diagrams look at the internals of an object – more next year
22
Flow charts don’t work as well with objects but can be useful for detailed logic
23
There are tools for this Tools to help produce them Tools to produce code from them Tools to take code and produce diagrams
24
What do I honestly use to design? Start usually with a rough use case diagram then a very messy object diagram then a rough class diagram then I pick a use case and using my pen move around the object diagram being sure I can do that use case (bit like interaction diagram usually that involves jotting down some pseudocode, which like on previous gives me more methods for the class diagram and more things to pseudocode – quit when it gets easy
25
But design is also about communication What I said on last slide is fine to get started But …. –You may be working with others –You may not be the one who is maintaining the system –You may forget what you did and why So readable design documentation is needed
26
Worksheet four ??
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.