sequence diagrams
play

Sequence Diagrams Ferd van Odenhoven Fontys Hogeschool voor - PowerPoint PPT Presentation

Sequence Diagrams Example and Assignment Sequence Diagrams Ferd van Odenhoven Fontys Hogeschool voor Techniek en Logistiek May 27, 2015 FvO/FHTBM Sequence Diagrams May 27, 2015 1/17 Sequence Diagrams Sequence Diagram Elements Example and


  1. Sequence Diagrams Example and Assignment Sequence Diagrams Ferd van Odenhoven Fontys Hogeschool voor Techniek en Logistiek May 27, 2015 FvO/FHTBM Sequence Diagrams May 27, 2015 1/17

  2. Sequence Diagrams Sequence Diagram Elements Example and Assignment CRC-cards Sequence Diagram Definition A sequence diagram displays how a use case could evolve using messages between objects / participants. The messages follow the relations between classes in the class diagram. Typically each concrete scenario has its own sequence diagram. If the domain changes, the sequence diagram might have to be altered too! FvO/FHTBM Sequence Diagrams May 27, 2015 2/17

  3. Sequence Diagrams Sequence Diagram Elements Example and Assignment CRC-cards Sequence Diagram Elements In UML1 the messages are between objects , as of UML2 they are termed more general as participants . In de figure below the participant is an object. UML 1 UML 2 :Library :Library Member make reservation {found message} make reservation Note.. Note.. Object: UML 1 Found message: since UML 2 Actor: UML 1 & 2 Objects: no underlining in UML2 Figure : Message with actor (uml 1 & 2) or ‘found message’ (uml 2) FvO/FHTBM Sequence Diagrams May 27, 2015 3/17

  4. Sequence Diagrams Sequence Diagram Elements Example and Assignment CRC-cards Sequence Diagram Elements Participants can be anonymous objects or named objects. On the life line, a bar denotes that a participant is active :Book book:Book Note.. Note.. Anonymous Object Named Object Figure : Objects are the participants here. FvO/FHTBM Sequence Diagrams May 27, 2015 4/17

  5. Sequence Diagrams Sequence Diagram Elements Example and Assignment CRC-cards Sequence Diagram Elements Messages may or may not (if the diagram is unambiguous) have return values. A return message is drawn as a dashed arrow. ‘Self calls’ are messages to itself ( this ) object. book:Book :Library Note.. Message message name Note.. this is a self call return value Figure : Messages with returns and self calls. FvO/FHTBM Sequence Diagrams May 27, 2015 5/17

  6. Sequence Diagrams Sequence Diagram Elements Example and Assignment CRC-cards Sequence Diagram Elements UML 1 UML 2.x new Reservation(copy) res:Reservation new Reservation(copy) res:Reservation delete(res) delete(res) Figure : Construction and destruction of Objects. In case of garbage collection there is no destructor method! Showing only the cross symbol shows that the object is no longer present. FvO/FHTBM Sequence Diagrams May 27, 2015 6/17

  7. Sequence Diagrams Sequence Diagram Elements Example and Assignment CRC-cards CRC-cards A CRC-card looks as follows : Class: Nr: Responsibilities: Collaborations: Table : CRC-cards can help in dividing the responsibilities over the relevant classes. FvO/FHTBM Sequence Diagrams May 27, 2015 7/17

  8. Sequence Diagrams Sequence Diagram Elements Example and Assignment CRC-cards Why use CRC-cards for sequence diagrams? A sequence diagram starts at the right object: the one that has the responsibility to start this use case. If for the next step not this object but another object is responsible, a CRC-cards could provie this information. If the sequence diagram looks awkward: too complicated or messy, redistribute certain responsibilities or change the domain model, alter crc-cards and the new sequence diagram should be better. FvO/FHTBM Sequence Diagrams May 27, 2015 8/17

  9. Sequence Diagrams Library Example and Assignment Assignment Library Example: Usecase Use Case: Make book lending Actor: Member m1 of the library Precondition: Actor is logged on Description: 1. Actor searches for book with data: title ‘The Ring 1’ and author ‘Tolkien’ 2. Actor activates ‘make rental’ 3. System checks if there is a copy available 4. A copy is available and is set to borrowed 5. A new rental has been created 6. New rental is added to rentals of member m1 7. System returns a message: “Rental creation OK.” Extensions: Exceptions: FvO/FHTBM Sequence Diagrams May 27, 2015 9/17

  10. Sequence Diagrams Library Example and Assignment Assignment Library Class Diagram o ff ers has <<facade>> Book Copy 1 * * Library title isBorrowed has author 1 1 1..25 <<create>> * <<create>> Reservation for has startDate for endDate * 1 * Rental Member has startDate id 1 endDate * FvO/FHTBM Sequence Diagrams May 27, 2015 10/17

  11. Sequence Diagrams Library Example and Assignment Assignment Facade pattern FvO/FHTBM Sequence Diagrams May 27, 2015 11/17

  12. Sequence Diagrams Library Example and Assignment Assignment CRC-card Library Class: Library Nr: 1 Responsibilities: Collaborations: - Manage accounts and members Account - Manage book catalog Member - Create lending Book - Create and make reservations Copy Rental Reservation Table : CRC-card for the Library class FvO/FHTBM Sequence Diagrams May 27, 2015 12/17

  13. Sequence Diagrams Library Example and Assignment Assignment CRC-card Book Class: Book Nr: 2 Responsibilities: Collaborations: - Manage Reservations for this book Reservation - Find member who has Member a reservation for this book Book - Add and remove reservations Table : CRC-card for the Book class FvO/FHTBM Sequence Diagrams May 27, 2015 13/17

  14. Sequence Diagrams Library Example and Assignment Assignment CRC-card Member Class: Member Nr: 3 Responsibilities: Collaborations: - Manage Rentals for this member Rental Table : CRC-card for the Member class Class: Reservation Nr: 4 Responsibilities: Collaborations: - Store member that has this reservation Member Table : CRC-card for the Reservation class FvO/FHTBM Sequence Diagrams May 27, 2015 14/17

  15. Sequence Diagrams Library Example and Assignment Assignment Library Sequence Diagram :Library book:Book copy1:Copy m1:Member make today a rental for book: "de Ring 1" by search book "T olkien" for member m1 book get available copy copy1 Found message for every user who set borrowed true can be an actor for this use case. new Rental ren1:Rental (copy1, today) add Rental (ren1) FvO/FHTBM Sequence Diagrams May 27, 2015 15/17

  16. Sequence Diagrams Library Example and Assignment Assignment Object diagram after creating rental copy2:Copy :Library book:Book copy3:Copy copy1:Copy borrowed=true m1:Member ren1:Rental Figure : The object ren1 and the connections to and from this object are new. The library has three copies of the corresponding book. FvO/FHTBM Sequence Diagrams May 27, 2015 16/17

  17. Sequence Diagrams Library Example and Assignment Assignment Train company Create a first version of a class diagram by introducing a facade class with name : TrainCompany Choose two use-cases you made earlier. Make sequence diagrams for these use cases. Do not add superfluous much details! Only the essentials to understand the sequence of steps. Improve your domain model if necessary and comment on your changes. FvO/FHTBM Sequence Diagrams May 27, 2015 17/17

Recommend


More recommend