1 / 38

Sequence diagram

Sequence diagram. E. Haodudin Nurkifli Teknik Informatika Universitas Ahmad Dahlan Pertemuan : 6. Sequence Diagram. Merupakan suatu diagram interaksi yang memodelkan suatu skenario tunggal yang dijalankan pada sistem

jives
Télécharger la présentation

Sequence diagram

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. Sequence diagram E. Haodudin Nurkifli Teknik Informatika Universitas Ahmad Dahlan Pertemuan : 6

  2. Sequence Diagram • Merupakan suatu diagram interaksi yang memodelkan suatu skenario tunggal yang dijalankan pada sistem • Digunakan untuk memperlihatkan interaksi antar obyek dalam perintah yang berurut. • Tujuan utama adalah mendefinisikan urutan kejadian yang dapat menghasilkan output yang diinginkan

  3. Sequence Diagram • Partisipan : obyek atau entitas yang bertindak dalam sequence diagram • Message : komunikasi antar obyek partisipan • Terdapat 2 tipe garis yaitu vertikal dan horisontal • Vertikal : waktu  maju berdasarkan waktu • Horisontal : obyek mana yang beraksi

  4. Elemen Notasi • Didefinisikan pada UML 2.0 • Digambarkan dalam bentuk frame • Bersifat optional untuk menggambarkan batas grafis suatu diagram.

  5. Elemen Notasi (cont.) • A sequence diagram that has incoming and outgoing messages

  6. Elemen Notasi (Labeling) • The UML specification provides specific text values for diagram types • sd = Sequence Diagram, • activity = Activity Diagram, • use case = Use Case Diagram DiagramType DiagramName

  7. Types of Interaction • Creation • Menunjukkan pesan yang menyebabkan terjadinya pembentukan instan obyek. • Synchronous • Pesan yang dikirim oleh 1 obyek ke obyek lain dan obyek pertama menunggu sampai hasil aksi selesai. • Asynchronous • Pesan yang dikirim oleh 1 obyek ke obyek lain dan obyek pertama tidak menunggu sampai hasil aksi selesai. • Reply • Menunjukkan nilai kembali dari obyek ke obyek yang megirim pesan Sumber : schaum outline

  8. Guidelines for Building a UML Sequence Diagram • Set the context (i.e. scope the system) • Identify participating objects • Draw arbitrary lifelines for each class • Draw the duration of the objects on the class lifeline • Insert the object messages from top to bottom of diagram (time-based) • Check the diagram for completeness

  9. Lifelines • Elemen notasi lifeline terletak pada posisi atas diagram • Represent either roles or object instances that participate in the sequence being modeled • Standar penamaan lifeline : • Instance Name : Class Name

  10. Messages • The first message of a sequence diagram always starts at the top and is typically located on the left side of the diagram for readability. • Subsequent messages are then added to the diagram slightly lower then the previous message.

  11. Message (cont.) • the analyst object makes a call to the system object which is an instance of the ReportingSystem class. • The analyst object is calling the system object's getAvailableReports method. • The system object then calls the getSecurityClearance method with the argument of userId on the secSystem object, which is of the class type SecuritySystem • the secSystem object returns userClearance to the system object when the getSecurityClearance method is called. • The system object returns availableReports when the getAvailableReports method is called.

  12. Message (cont.) • the system object calling its determineAvailableReports method.

  13. Message (cont.) • Asynchronous Messages : digunakan pada proses konkurensi

  14. Guards • When modeling object interactions, there will be times when a condition must be met for a message to be sent to the object. • the guard is the text "[pastDueBalance = 0]." By having the guard on this message, the addStudent message will only be sent if the accounts receivable system returns a past due balance of zero

  15. Combined fragments (alternatives, options, and loops) • A combined fragment is used to group sets of messages together to show conditional flow in a sequence diagram. • The UML 2 specification identifies 11 interaction types for combined fragments.

  16. Alternatives • Alternatives are used to designate a mutually exclusive choice between two or more message sequences. • Alternatives allow the modeling of the classic "if then else" logic e.g. • if I buy three items, then I get 20% off my purchase; else I get 10% off my purchase.

  17. Alternatives (cont.)

  18. Option • The option combination fragment is used to model a sequence that, given a certain condition, will occur; otherwise, the sequence does not occur. • An option is used to model a simple "if then" statement (i.e., if there are fewer than five donuts on the shelf, then make two dozen more donuts).

  19. Option (Cont.) if a student's past due balance equals zero, then the addStudent, getCostOfClass, and chargeForClass messages are sent. If the student's past due balance does not equal zero, then the sequence skips sending any of the messages in the option combination fragment.

  20. Loops • Occasionally you will need to model a repetitive sequence. • In UML 2, modeling a repeating sequence has been improved with the addition of the loop combination fragment.

  21. Loops (cont.)

  22. Referencing another sequence diagram • Starting in UML 2, the "Interaction Occurrence" element was introduced. • Interaction occurrences add the ability to compose primitive sequence diagrams into complex sequence diagrams. • The text "ref" is placed inside the frame's namebox, and the name of the sequence diagram being referenced is placed inside the frame's content area along with any parameters to the sequence diagram.

  23. Interaction Occurrence

  24. Interaction Occurrence (cont.)

  25. Gates • Gates can be an easy way to model the passing of information between a sequence diagram and its context. • A gate is merely a message that is illustrated with one end connected to the sequence diagram's frame's edge and the other end connected to a lifeline

  26. Gates (cont.)

  27. Gates (cont.)

  28. Break • almost identical in every way to the option combined fragment, with two exceptions. • a break's frame has a namebox with the text "break" instead of "option." • when a break combined fragment's message is to be executed, the enclosing interaction's remainder messages will not be executed because the sequence breaks out of the enclosing interaction • break combined fragment is much like the break keyword in a programming language like C++ or Java • Breaks are most commonly used to model exception handling

  29. Parallel • When the processing time required to complete portions of a complex task is longer than desired, some systems handle parts of the processing in parallel • The parallel combination fragment is drawn using a frame, and you place the text "par" in the frame's namebox • break up the frame's content section into horizontal operands separated by a dashed line. • Each operand in the frame represents a thread of execution done in parallel.

  30. Parallel (cont.) A microwave is an example of an object that does two tasks in parallel

  31. Summary • The sequence diagram is a good diagram to use to document a system's requirements and to flush out a system's design. • The reason the sequence diagram is so useful is because it shows the interaction logic between the objects in the system in the time order that the interactions take place.

  32. References • UML 2.0 Superstructure Final Adopted Specification • UML 2 Sequence Diagram Overview • UML 2 Tutorial

  33. Try this yourself… Draw up a sequence diagram modelling the case when an advert campaign manager retrieves the details of a particular client’s advertising campaign and lists the details of a particular advert from the campaign. The sequence diagram should also show the case when a new advert is created. Only call messages (synchronous) should be used in this example and use any iteration conditions as you deem necessary. Objects to use: “CampainManager”, “Client”, “Campaign”, and “Advert”

  34. A Solution to Previous Slide

  35. Try this too… Create a sequence diagram modelling the behaviour of a PCB drilling machine. The machine will drill holes in a PCB of given dimensions at a set of given co-ordinates. Co-ordinates are given as a list, which must contain at least one set of co-ordinates. Drilling stops when the end of the list is reached or when a user interrupts the process.

  36. A Solution to Previous Slide

  37. Question

More Related