CS12420 Sequence Diagrams – a UML notation for modelling bahaviour Lynda Thomas [email protected]...
-
Upload
shannon-parrish -
Category
Documents
-
view
221 -
download
0
Transcript of CS12420 Sequence Diagrams – a UML notation for modelling bahaviour Lynda Thomas [email protected]...
![Page 1: CS12420 Sequence Diagrams – a UML notation for modelling bahaviour Lynda Thomas ltt@aber.ac.uk Images from Wikipedia unless credited or mine.](https://reader036.fdocuments.us/reader036/viewer/2022062304/56649ecf5503460f94bdd60d/html5/thumbnails/1.jpg)
CS12420Sequence Diagrams – a UML
notation for modelling bahaviour
Lynda Thomas
Images from Wikipedia unless credited or mine
![Page 2: CS12420 Sequence Diagrams – a UML notation for modelling bahaviour Lynda Thomas ltt@aber.ac.uk Images from Wikipedia unless credited or mine.](https://reader036.fdocuments.us/reader036/viewer/2022062304/56649ecf5503460f94bdd60d/html5/thumbnails/2.jpg)
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
![Page 3: CS12420 Sequence Diagrams – a UML notation for modelling bahaviour Lynda Thomas ltt@aber.ac.uk Images from Wikipedia unless credited or mine.](https://reader036.fdocuments.us/reader036/viewer/2022062304/56649ecf5503460f94bdd60d/html5/thumbnails/3.jpg)
ClassDiagram
ObjectDiagram
![Page 4: CS12420 Sequence Diagrams – a UML notation for modelling bahaviour Lynda Thomas ltt@aber.ac.uk Images from Wikipedia unless credited or mine.](https://reader036.fdocuments.us/reader036/viewer/2022062304/56649ecf5503460f94bdd60d/html5/thumbnails/4.jpg)
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
![Page 5: CS12420 Sequence Diagrams – a UML notation for modelling bahaviour Lynda Thomas ltt@aber.ac.uk Images from Wikipedia unless credited or mine.](https://reader036.fdocuments.us/reader036/viewer/2022062304/56649ecf5503460f94bdd60d/html5/thumbnails/5.jpg)
But that doesn’t tell you design i.e. in what order things happen
or how to write the methods
![Page 6: CS12420 Sequence Diagrams – a UML notation for modelling bahaviour Lynda Thomas ltt@aber.ac.uk Images from Wikipedia unless credited or mine.](https://reader036.fdocuments.us/reader036/viewer/2022062304/56649ecf5503460f94bdd60d/html5/thumbnails/6.jpg)
Sequence diagrams do that
• Let’s use google
• http://en.wikipedia.org/wiki/Sequence_diagrams
• http://www.ibm.com/developerworks/rational/library/3101.html
• http://www.agilemodeling.com/artifacts/sequenceDiagram.htm
![Page 7: CS12420 Sequence Diagrams – a UML notation for modelling bahaviour Lynda Thomas ltt@aber.ac.uk Images from Wikipedia unless credited or mine.](https://reader036.fdocuments.us/reader036/viewer/2022062304/56649ecf5503460f94bdd60d/html5/thumbnails/7.jpg)
TIME
![Page 8: CS12420 Sequence Diagrams – a UML notation for modelling bahaviour Lynda Thomas ltt@aber.ac.uk Images from Wikipedia unless credited or mine.](https://reader036.fdocuments.us/reader036/viewer/2022062304/56649ecf5503460f94bdd60d/html5/thumbnails/8.jpg)
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
![Page 9: CS12420 Sequence Diagrams – a UML notation for modelling bahaviour Lynda Thomas ltt@aber.ac.uk Images from Wikipedia unless credited or mine.](https://reader036.fdocuments.us/reader036/viewer/2022062304/56649ecf5503460f94bdd60d/html5/thumbnails/9.jpg)
But usually used to look at how objects in an OO system interact
Let’s have a look at the .pdf filehttp://csis.pace.edu/~marchese/CS389/L9/Sequence%20Diagram%20Tutorial.pdf
for the syntax
![Page 10: CS12420 Sequence Diagrams – a UML notation for modelling bahaviour Lynda Thomas ltt@aber.ac.uk Images from Wikipedia unless credited or mine.](https://reader036.fdocuments.us/reader036/viewer/2022062304/56649ecf5503460f94bdd60d/html5/thumbnails/10.jpg)
Cute (but just noticed error) - Three Little Pigshttp://www.tracemodeler.com/articles/pimp-my-diagram-three-little-pigs/index.html?src=rss
![Page 11: CS12420 Sequence Diagrams – a UML notation for modelling bahaviour Lynda Thomas ltt@aber.ac.uk Images from Wikipedia unless credited or mine.](https://reader036.fdocuments.us/reader036/viewer/2022062304/56649ecf5503460f94bdd60d/html5/thumbnails/11.jpg)
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
![Page 12: CS12420 Sequence Diagrams – a UML notation for modelling bahaviour Lynda Thomas ltt@aber.ac.uk Images from Wikipedia unless credited or mine.](https://reader036.fdocuments.us/reader036/viewer/2022062304/56649ecf5503460f94bdd60d/html5/thumbnails/12.jpg)
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
![Page 13: CS12420 Sequence Diagrams – a UML notation for modelling bahaviour Lynda Thomas ltt@aber.ac.uk Images from Wikipedia unless credited or mine.](https://reader036.fdocuments.us/reader036/viewer/2022062304/56649ecf5503460f94bdd60d/html5/thumbnails/13.jpg)
0..*
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 data1..1
0..*-translators
0..*-allDocs
+doEmerTrans (): void
![Page 14: CS12420 Sequence Diagrams – a UML notation for modelling bahaviour Lynda Thomas ltt@aber.ac.uk Images from Wikipedia unless credited or mine.](https://reader036.fdocuments.us/reader036/viewer/2022062304/56649ecf5503460f94bdd60d/html5/thumbnails/14.jpg)
![Page 15: CS12420 Sequence Diagrams – a UML notation for modelling bahaviour Lynda Thomas ltt@aber.ac.uk Images from Wikipedia unless credited or mine.](https://reader036.fdocuments.us/reader036/viewer/2022062304/56649ecf5503460f94bdd60d/html5/thumbnails/15.jpg)
0..*
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 data1..1
0..*-translators
0..*-allDocs
+getFreeTrans (): Translator
+doEmerTrans (): void
![Page 16: CS12420 Sequence Diagrams – a UML notation for modelling bahaviour Lynda Thomas ltt@aber.ac.uk Images from Wikipedia unless credited or mine.](https://reader036.fdocuments.us/reader036/viewer/2022062304/56649ecf5503460f94bdd60d/html5/thumbnails/16.jpg)
aTrans=
![Page 17: CS12420 Sequence Diagrams – a UML notation for modelling bahaviour Lynda Thomas ltt@aber.ac.uk Images from Wikipedia unless credited or mine.](https://reader036.fdocuments.us/reader036/viewer/2022062304/56649ecf5503460f94bdd60d/html5/thumbnails/17.jpg)
0..*
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 data1..1
0..*-translators
0..*-allDocs
+getFreeTrans (): Translator
+doEmerTrans (): void
+doEmer(DocInfo d): void
![Page 18: CS12420 Sequence Diagrams – a UML notation for modelling bahaviour Lynda Thomas ltt@aber.ac.uk Images from Wikipedia unless credited or mine.](https://reader036.fdocuments.us/reader036/viewer/2022062304/56649ecf5503460f94bdd60d/html5/thumbnails/18.jpg)
![Page 19: CS12420 Sequence Diagrams – a UML notation for modelling bahaviour Lynda Thomas ltt@aber.ac.uk Images from Wikipedia unless credited or mine.](https://reader036.fdocuments.us/reader036/viewer/2022062304/56649ecf5503460f94bdd60d/html5/thumbnails/19.jpg)
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
![Page 20: CS12420 Sequence Diagrams – a UML notation for modelling bahaviour Lynda Thomas ltt@aber.ac.uk Images from Wikipedia unless credited or mine.](https://reader036.fdocuments.us/reader036/viewer/2022062304/56649ecf5503460f94bdd60d/html5/thumbnails/20.jpg)
Detailed:Initialize total to zeroInitialize counter to zeroInput the first gradewhile 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 /counterprint the average
elseprint '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=aTranstranslator.doEmer()
Now need to elaborate doEmer() in Translator
![Page 21: CS12420 Sequence Diagrams – a UML notation for modelling bahaviour Lynda Thomas ltt@aber.ac.uk Images from Wikipedia unless credited or mine.](https://reader036.fdocuments.us/reader036/viewer/2022062304/56649ecf5503460f94bdd60d/html5/thumbnails/21.jpg)
Here is a vending machine
State diagrams look at the internals of an object – more next year
![Page 22: CS12420 Sequence Diagrams – a UML notation for modelling bahaviour Lynda Thomas ltt@aber.ac.uk Images from Wikipedia unless credited or mine.](https://reader036.fdocuments.us/reader036/viewer/2022062304/56649ecf5503460f94bdd60d/html5/thumbnails/22.jpg)
Flow charts don’t work as well with objects but can be useful for detailed logic
![Page 23: CS12420 Sequence Diagrams – a UML notation for modelling bahaviour Lynda Thomas ltt@aber.ac.uk Images from Wikipedia unless credited or mine.](https://reader036.fdocuments.us/reader036/viewer/2022062304/56649ecf5503460f94bdd60d/html5/thumbnails/23.jpg)
There are tools for this
• Tools to help produce them
• Tools to produce code from them
• Tools to take code and produce diagrams
![Page 24: CS12420 Sequence Diagrams – a UML notation for modelling bahaviour Lynda Thomas ltt@aber.ac.uk Images from Wikipedia unless credited or mine.](https://reader036.fdocuments.us/reader036/viewer/2022062304/56649ecf5503460f94bdd60d/html5/thumbnails/24.jpg)
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
![Page 25: CS12420 Sequence Diagrams – a UML notation for modelling bahaviour Lynda Thomas ltt@aber.ac.uk Images from Wikipedia unless credited or mine.](https://reader036.fdocuments.us/reader036/viewer/2022062304/56649ecf5503460f94bdd60d/html5/thumbnails/25.jpg)
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
![Page 26: CS12420 Sequence Diagrams – a UML notation for modelling bahaviour Lynda Thomas ltt@aber.ac.uk Images from Wikipedia unless credited or mine.](https://reader036.fdocuments.us/reader036/viewer/2022062304/56649ecf5503460f94bdd60d/html5/thumbnails/26.jpg)
Worksheet four
• ??