1 / 26

CS12420 Sequence Diagrams – a UML notation for modelling bahaviour

CS12420 Sequence Diagrams – a UML notation for modelling bahaviour. Lynda Thomas ltt@aber.ac.uk. Images from Wikipedia unless credited or mine. Current UML - recap. Class diagrams tell you: the static structure of the system the relationships between the data

Download Presentation

CS12420 Sequence Diagrams – a UML notation for modelling bahaviour

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS12420Sequence 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/library/3101.html • http://www.agilemodeling.com/artifacts/sequenceDiagram.htm

  7. T I M E

  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 interactLet’s have a look at the .pdf filehttp://csis.pace.edu/~marchese/CS389/L9/Sequence%20Diagram%20Tutorial.pdffor the syntax

  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 Application //runs menu Model //holds data 1..1 LinguisticUnit //a word or phrase 0..* +emerTrans (): void +doEmerTrans (): void 0..* -allDocs 0..* -translators 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 0..* -myDocs 0..1-trans

  14. 0..* -dictionary Application //runs menu Model //holds data 1..1 LinguisticUnit //a word or phrase 0..* +emerTrans (): void +doEmerTrans (): void +getFreeTrans (): Translator 0..* -allDocs 0..* -translators 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 0..* -myDocs 0..1-trans

  15. aTrans=

  16. 0..* -dictionary Application //runs menu Model //holds data 1..1 LinguisticUnit //a word or phrase 0..* +emerTrans (): void +doEmerTrans (): void +getFreeTrans (): Translator 0..* -allDocs 0..* -translators 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 0..* -myDocs 0..1-trans +doEmer(DocInfo d): void

  17. 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

  18. 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() 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' 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

  19. State diagrams look at the internals of an object – more next year Here is a vending machine

  20. Flow charts don’t work as well with objects but can be useful for detailed logic

  21. There are tools for this • Tools to help produce them • Tools to produce code from them • Tools to take code and produce diagrams

  22. 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

  23. 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

  24. Worksheet four • ??

More Related