Presentation is loading. Please wait.

Presentation is loading. Please wait.

CIE 203 Software Engineering Lecture 12: Sequence Diagrams

Similar presentations


Presentation on theme: "CIE 203 Software Engineering Lecture 12: Sequence Diagrams"— Presentation transcript:

1 CIE 203 Software Engineering Lecture 12: Sequence Diagrams
Mohammad El-Ramly, PhD 2016

2 Chapter 5: Modelling with classes
Last 2 Lectures Fundamentals of Databases The Relational Model SQL Data Modelling Chapter 5: Modelling with classes © Lethbridge/Laganière 2012

3 Chapter 5: Modelling with classes
Previous 2 Lectures UML Class Diagrams Associations Generalization Aggregations Modelling with Classes Static View of the System Chapter 5: Modelling with classes © Lethbridge/Laganière 2012

4 Outline Update about project phase 2. Where are we now ?
why modelling software ? Sequence diagram ? Dynamic View of the System © Lethbridge/Laganière 2012

5 Chapter 5: Modelling with classes
© Lethbridge/Laganière 2012

6 I. What is needed in SD? (Project Phase 2)
© Lethbridge/Laganière 2012

7 What is needed in SD? (Project Phase 2)
© Lethbridge/Laganière 2012

8 What is needed in SD? (Project Phase 2)
© Lethbridge/Laganière 2012

9 What is needed in SD? (Project Phase 2)
© Lethbridge/Laganière 2012

10 Chapter 5: Modelling with classes
© Lethbridge/Laganière 2012

11 II. What is modeling? Modeling consists of building an abstraction of reality. Abstractions are simplifications because: They ignore irrelevant details and They only represent the relevant details. What is relevant or irrelevant depends on the purpose of the model.

12 Example: street map

13 Why modeling software? Software is getting more complex
Windows XP > 40 million lines of code A single programmer cannot manage this amount of code in its entirety. Code is not easily understandable by developers who did not write it We need simpler representations for complex systems Modeling is a way for dealing with complexity

14 Application and Solution Domain
Application Domain (Requirements Analysis): The environment in which the system is operating Solution Domain (System Design, Object Design): The available technologies to build the system

15 Object-oriented Modeling
Solution Domain (Phenomena) Application Domain (Phenomena) System Model (Concepts) (Analysis) System Model (Concepts) (Design) Summary Display UML Package MapDisplay FlightPlanDatabase Aircraft TrafficController FlightPlan Airport TrafficControl TrafficControl

16 UML: First Pass You can model 80% of problems using 20% UML
We teach you those 20% 80-20 rule: Pareto principle ( 80% of the profits come from 20% of the customers 80% of your complaints come from 20% of your customers 80% of your profits come from 20% of the time you spend 80% of your sales come from 20% of your products

17 UML: First Pass / Second Pass
Use case diagrams The functional behavior of the system as seen by the user Class diagrams The static structure of the system: Objects, attributes, associations Sequence diagrams The dynamic behavior between objects of the system to implement use cases State diagrams The dynamic behavior of an individual object Statechart diagrams Describe the dynamic behavior of an individual object (essentially a finite state automaton) Activity Diagrams Model the dynamic behavior of a system, in particular the workflow (essentially a flowchart)

18 © Lethbridge/Laganière 2012

19 III. (8.1) Interaction Diagrams
Interaction diagrams are used to model the dynamic aspects of a software system They help visualizing how the system runs. An interaction diagram is often built from a use case (user story) and a class diagram. The objective is to show how a set of objects accomplish the required interactions with an actor. Chapter 8: Modelling Interactions and Behaviour © Lethbridge/Laganière 2005

20 Interactions and messages
Interaction diagrams show how a set of actors and objects interact with each other via messages (method calls) to perform: The steps of a use case (user story) Chapter 8: Modelling Interactions and Behaviour © Lethbridge/Laganière 2005

21 Elements found in interaction diagrams
Instances of classes Shown as boxes with the class and object identifier underlined Actors Use the stick-person symbol as in use case diagrams Messages Shown as arrows from actor to object, or from object to object Chapter 8: Modelling Interactions and Behaviour © Lethbridge/Laganière 2005

22 Creating interaction diagrams
You should develop first a class diagram and a use case model before starting to create an interaction diagram. There are two kinds of interaction diagrams: Sequence diagrams Communication diagrams Chapter 8: Modelling Interactions and Behaviour © Lethbridge/Laganière 2005

23 Sequence diagrams – an example
Chapter 8: Modelling Interactions and Behaviour © Lethbridge/Laganière 2005

24 Chapter 8: Modelling Interactions and Behaviour
Sequence diagrams A sequence diagram shows the sequence of messages exchanged by the set of objects performing a certain task The objects are arranged horizontally across the diagram. The actor that initiates the interaction is shown on the left. The vertical dimension represents time. Chapter 8: Modelling Interactions and Behaviour © Lethbridge/Laganière 2005

25 Chapter 8: Modelling Interactions and Behaviour
Sequence diagrams A sequence diagram shows the sequence of messages exchanged by the set of objects performing a certain task A vertical line, called a lifeline, is attached to each object or actor. A message is represented as an arrow between activation boxes of the sender and receiver. A message is labelled and can have an argument list and a return value. Chapter 8: Modelling Interactions and Behaviour © Lethbridge/Laganière 2005

26 Sequence diagram notation: Frames
Chapter 8: Modelling Interactions and Behaviour © Lethbridge/Laganière 2005

27 Sequence diagram notation: Lifeline
Sequence diagrams are organized according to time Each participant has a corresponding lifeline Each vertical dotted line is a lifeline, representing the time Chapter 8: Modelling Interactions and Behaviour © Lethbridge/Laganière 2005

28 Sequence diagram notation: Lifeline names
seoclecturer An object named secolecturer seoclecturer:Lecturer An object named seoclecturer of class Lecturer :Lecturer An anonymous object of class Lecturer lecturer[i]: Lecturer The object lecturer that is selected by the index value i Chapter 8: Modelling Interactions and Behaviour © Lethbridge/Laganière 2005

29 Sequence diagram notation: Messages
Chapter 8: Modelling Interactions and Behaviour © Lethbridge/Laganière 2005

30 Sequence diagram notation: Messages
Chapter 8: Modelling Interactions and Behaviour © Lethbridge/Laganière 2005

31 Sequence diagram notation
Element Creation: when an element is created during an interaction, the communication that creates the element is shown with its arrowhead to the element Element Destruction: When an element is destroyed during an interaction, the communication that destroys the element is shown with its arrowhead to the elements lifeline where the destruction is marked with a large X symbol Chapter 8: Modelling Interactions and Behaviour © Lethbridge/Laganière 2005

32 Chapter 8: Modelling Interactions and Behaviour
© Lethbridge/Laganière 2005

33 Sequence diagrams: same example, more details
Chapter 8: Modelling Interactions and Behaviour © Lethbridge/Laganière 2005

34 Sequence diagrams An example with replicated messages
Chapter 8: Modelling Interactions and Behaviour © Lethbridge/Laganière 2005

35 Sequence diagrams: An example with object deletion
If an object’s life ends, this is shown with an X at the end of the lifeline Chapter 8: Modelling Interactions and Behaviour © Lethbridge/Laganière 2005

36 Why not just code it? Sequence diagrams are close to code level. Why not just code up that use case rather than drawing it as a sequence diagram? a good sequence diagram is still a bit above the level of the real code. sequence diagrams are language-independent and can be coded in many different languages non-coders can do / read sequence diagrams Sequence diagrams are visual representations of the program functionality.

37 Chapter 5: Modelling with classes
© Lethbridge/Laganière 2012

38 Exercise For the given library system, draw a sequence diagram for each given use case.

39 Libary System Use Case Diagram
Library system Issue a Book Copy Return a Book Copy Renew Book Copy User Librarian Manage Catalog Manage Users Search Catalog

40 Libary System Class Diagram
GUI Catalog - ???? ???? findBooks(title, au) ??????() << enumeration >> UserStatus Active Suspended BorrowedMax NoneExistant LibrarySystem maxAllowedBooks searchCatalog(title, auth) checkUserStatus(ID) 1 1 * * User ID: String name: String status: Ustatus nBorrowed: int checkStatus() borrowBook(copy) Book - title: String - author: String - isAvailable getBookInfo() getCopiesInfo() issueCopy(copy) BookCopy ID: String isAvailable checkStatus () getCopyInfo() * 1 * Record

41 Search Catalog Use Case
Name: Search Catalog B. Actors: User, Librarian C. Goals: Find information about book(s) by title or author D. Steps: Actor System 1- Enter title and/or author 2- Display list of matching books E. Exceptional Flow: 1- Enter empty criterion 2- The entire catalog is listed Chapter 5: Modelling with classes © Lethbridge/Laganière 2012

42 Chapter 5: Modelling with classes
Issue Book Use Case Name: Issue Book B. Actors: Librarian C. Goals: Issue a book to a borrower if his status permits D. Steps: Actor System 1- Enter user’s ID 2- Display’s info and user status 3- If allowed to borrow, 4- Create a borrowing record enter book copy ID 5- Update user’s number of books borrowed 6- Update book’s availability Chapter 5: Modelling with classes © Lethbridge/Laganière 2012

43 Chapter 5: Modelling with classes
Issue Book Use Case Name: Issue Book E. Exceptional Flow 1: User is None Existent Actor System 1- Enter user’s ID 2- If user ID does not exist, display a message saying so Exceptional Flow 2: User is not allowed to borrow 1- Enter user’s ID 2- Display’s info and user status 3- If user is suspended or borrowed max number, deny issuing him books. Chapter 5: Modelling with classes © Lethbridge/Laganière 2012

44 Libary System Class Diagram
GUI Catalog - ???? findBooks(title, au) ??????() << enumeration >> UserStatus Active Suspended BorrowedMax NoneExistant LibrarySystem maxAllowedBooks searchCatalog(title, auth) checkUserStatus(ID) 1 1 * * User ID: String name: String status: Ustatus nBorrowed: int checkStatus() borrowBook(copy) Book - title: String - author: String - isAvailable getBookInfo() getCopiesInfo() issueCopy(copy) BookCopy ID: String isAvailable checkStatus () getCopyInfo() * 1 * Record

45 Sequence diagram exercise
Do a sequence diagram for the following casual use case description: Add Calendar Appointment : The scenario begins when the user chooses to add a new appointment in the UI. The UI notices which part of the calendar is active and pops up an Add Appointment window for that date and time. The user enters the necessary information about the appointment's name, location, start and end times. The UI will prevent the user from entering an appointment that has invalid information, such as an empty name or negative duration. The calendar records the new appointment in the user's list of appointments. Any reminder selected by the user is added to the list of reminders. If the user already has an appointment at that time, the user is shown a warning message and asked to choose an available time or replace the previous appointment. If the user enters an appointment with the same name and duration as an existing group meeting, the calendar asks the user whether he/she intended to join that group meeting instead. If so, the user is added to that group meeting's list of participants.

46 Chapter 5: Modelling with classes
© Lethbridge/Laganière 2012

47 Chapter 5: Modelling with classes
Today Review of where we are Info about Project Phase 2 Importance of Modeling Sequence Diagrams Chapter 5: Modelling with classes © Lethbridge/Laganière 2012

48 Chapter 5: Modelling with classes
Readings Very Important R7: Chapter 8 (Modeling interactions and behavior) of OOSE, 2nd ed by Tim. Lethbridge Read section 8.1 from page 285 to page 290 Appendix A: Summary of UML Syntax – page 471 and 472 reference.html Video by Derek Banas Chapter 5: Modelling with classes © Lethbridge/Laganière 2012


Download ppt "CIE 203 Software Engineering Lecture 12: Sequence Diagrams"

Similar presentations


Ads by Google