Essentials of interaction diagrams Lecture 23 & 24.

Slides:



Advertisements
Similar presentations
© 2005 by Prentice Hall Appendix 3 Object-Oriented Analysis and Design Modern Systems Analysis and Design Fourth Edition Jeffrey A. Hoffer Joey F. George.
Advertisements

1 CIS224 Software Projects: Software Engineering and Research Methods Lecture 6 State Machine and Activity Diagrams (Based on Stevens and Pooley (2006,
Object-Oriented Analysis and Design CHAPTERS 15: UML INTERACTION DIAGRAMS 1.
UML (Sequence Diagrams, Collaboration and State Chart Diagrams) Presentation By - SANDEEP REDDY CHEEDEPUDI (Student No: ) - VISHNU CHANDRADAS (Student.
© 2006 ITT Educational Services Inc. SE350 System Analysis for Software Engineers: Unit 9 Slide 1 Appendix 3 Object-Oriented Analysis and Design.
Software Engineering COMP 201
Lecturer: Sebastian Coope Ashton Building, Room G.18 COMP 201 web-page: Lecture.
Chapter 15: System Modeling with UML
Systems Analysis and Design in a Changing World, Fourth Edition
Design Patterns in Java Appendix D UML at a Glance Summary prepared by Kirk Scott 1.
Essentials of class models. 2 A very simple class model In UML, a class is shown in a class diagram as a rectangle giving its name.
© 2005 Prentice Hall8-1 Stumpf and Teague Object-Oriented Systems Analysis and Design with UML.
Essentials of interaction diagrams Lecture Outline Collaborations Interaction on collaboration diagrams Sequence diagrams Messages from an object.
Essentials of state and activity diagram Lecture 24.
© 2005 Prentice Hall4-1 Stumpf and Teague Object-Oriented Systems Analysis and Design with UML.
C++ Training Datascope Lawrence D’Antonio Lecture 11 UML.
© Copyright Eliyahu Brutman Programming Techniques Course.
SE-565 Software System Requirements More UML Diagrams.
Unified Modeling Language
UML Sequence Diagrams Michael L. Collard, Ph.D. Department of Computer Science Kent State University.
State and Sequence Diagrams Modelling dynamic information So far we have seen: Use Case Diagrams – requirements capture, interface.
Interactions. 2 Objects communicate with each other by sending messages. Sending a message is another name for a member function call. –Some C++ examples.
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 8: Modelling Interactions and Behaviour.
程建群 博士(Dr. Jason Cheng) 年03月
State diagrams Interaction diagrams –Sequence diagrams –Collaboration diagrams Object orientation Part 4: Dynamic Modeling.
Copyright 2002 Prentice-Hall, Inc. Modern Systems Analysis and Design Third Edition Jeffrey A. Hoffer Joey F. George Joseph S. Valacich Chapter 20 Object-Oriented.
The Object-Oriented Approach to Requirements
Systems Analysis and Design in a Changing World, Fifth Edition
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 9: Interaction.
Interaction Models (2): Sequence Diagrams Extracted from textbook: Object Oriented Modeling and Design with UML M. Blaha, J. Rumbaugh 1.
1 Modeling interactions and behavior Lecturer Dr. Mai Fadel.
Programming Logic and Design Fourth Edition, Comprehensive Chapter 15 System Modeling with the UML.
Unit 1 INTRODUCTION TO MODELING AND CLASS MODEL Ref : L7-UML.PDF.
UML diagrams What is UML UML diagrams –Static modeoing –Dynamic modeling 1.
7 Systems Analysis and Design in a Changing World, Fifth Edition.
Sequence diagram in UML Martin Palkovik. Sequence diagram  It is a graphic representation of system operations based on chronology - a time sequence.
An Introduction to the Unified Modeling Language
Discovering object interaction. Use case realisation The USE CASE diagram presents an outside view of the system. The functionality of the use case is.
Course Instructor: Kashif Ihsan 1. Chapter # 3 2.
Object-Oriented Analysis and Design 1 Mira Balaban & Arnon Sturm Object-Oriented Analysis and Design Session 3a: Behavioral Modeling - Interactions.
Design Jon Walker. More UML ● What is UML again?
Sequence Diagrams CSIS3600. Sequence Diagrams A sequence diagram shows an interaction arranged in time sequence. In particular, it shows the objects participating.
Appendix D UML at a Glance Summary prepared by Kirk Scott 1.
1 Kyung Hee University Statecharts Spring Kyung Hee University Specifying Objects’ Behaviour  Interaction diagrams show message-passing behaviour.
Introduction to UML CS A470. What is UML? Unified Modeling Language –OMG Standard, Object Management Group –Based on work from Booch, Rumbaugh, Jacobson.
CS212: Object Oriented Analysis and Design Lecture 34: UML Activity and Collaboration diagram.
Systems Analysis and Design in a Changing World, Fourth Edition
CS212: Object Oriented Analysis and Design Lecture 33: Class and Sequence Diagram.
INFO 620Lecture #71 Information Systems Analysis and Design Design Class Diagrams and others INFO 620 Glenn Booker.
Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall Object-Oriented Systems Analysis and Design Using UML Systems Analysis and Design,
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 10: Statecharts.
Chapter 3: Introducing the UML
 The Sequence Diagram models the collaboration of objects based on a time sequence.  It shows how the objects interact with others in a particular scenario.
1 Kyung Hee University Interaction Diagrams Spring 2001.
Unified Modeling Language. What is UML? Standard language for specifying, visualizing, constructing, and documenting the artifacts of software systems,
Project 2: Phase 1 Submission 7 Late submissions 10% 10 No submissions 14% Better than project 1 phase 3 submissions 10-point bonus: If you catch the deadline.
Systems Analysis and Design in a Changing World, Fourth Edition
UML Diagrams By Daniel Damaris Novarianto S..
Course Outcomes of Object Oriented Modeling Design (17630,C604)
Object-Oriented Analysis and Design
Unified Modeling Language
Activity and State Transition Diagram
UML Diagrams Jung Woo.
Business System Development
Week 12: Activity & Sequence Diagrams
Chapter 20 Object-Oriented Analysis and Design
CIS 375 Bruce R. Maxim UM-Dearborn
Interaction diagrams Interaction diagrams are models that describe how groups of objects collaborate in some behavior. Typically, an interaction diagram.
CIS 375 Bruce R. Maxim UM-Dearborn
Appendix 3 Object-Oriented Analysis and Design
Presentation transcript:

Essentials of interaction diagrams Lecture 23 & 24

2 Outline Collaborations Interaction on collaboration diagrams Sequence diagrams Messages from an object to itself Suppressing detailed behaviour Creation and deletion of objects Timing

3 Important UML models We have now seen the two most important UML models: –The use case model, which describes the tasks which the system must help to perform –The class model, which describes the classes which are intended to achieve this and relationship between them UML’s interaction diagrams allow us to record in detail how objects interact to perform a task

4 Use case diagrams show the interaction of users of the system with the functionality of the system. A use case is a functional component of the system that accomplishes a specific task, and is represented by an ellipse. An actor, depicted as a stickman figure, is a user of the system performing a specific role. Use case diagrams are used early in the development process to refine the functional specifications, identify user interface requirements, and to define the scope of the project. Use Case Diagrams

5 Use Case Diagram Example

6 Class Diagrams A Class diagram shows the static structure of the system. It defines model elements such as classes, interfaces, and user- defined data types, their internal structure, and their relationships to each other. Relationships, or associations, are shown as lines connecting elements, and are annotated to describe the relationships and their cardinality (1..1, 1..*, 0..*, etc.). Inheritance (generalize/specialize), aggregation (comprises), and composition (has) relationships are also captured in this diagram. Class attributes and their data types are identified here, as are the operations and their return types. Visibility is indicated by +, #, or - for public, protected, or private. The class diagram plays a vital role in the transition from design to construction as it contains sufficient detail to begin the coding process. It is often used to partition responsibilities among the project team members, and to guide and measure the construction process.

7 Class Diagram Example

8 Collaborations UML provides two sorts of interaction diagram, –sequence and –collaboration diagrams. Collectively, the objects which interact to perform some task, together with the links between them, are known as a collaboration –Objects Each object is shown as rectangle, which is labelled objectName: className –Links Links between objects are shown like associations in the class model. –Actors Actors can be shown as on a use case diagram

9 A simple collaboration, showing no interaction A collaboration, without any interaction shown, is rather like an instance of part of the class model. It shows objects, links and actors

10 Interaction on collaboration diagrams Each labelled arrow represents a message sent from the object at the tail of the arrow to the object at the point of the arrow. Furthermore, the target object must understand the message That is, the class of the object at the point of the arrow must provide the appropriate operation

11 Sequence diagrams A sequence diagram shows the objects and actor which take part in a collaboration at the top of dashed lines. Sequence diagrams are applicable to modeling real-time interactive systems or complex scenarios.

12 Interaction shown on a sequence diagram

13 The vertical dimension of a sequence diagram represents time The horizontal dimension represents the different objects or roles that participate in the interactive sequence. An object’s lifeline is shown as a narrow vertical bar.

14 Time is assumed to pass as we move from top to bottom of the diagram. Messages between objects are shown as solid line arrows, and their returns are shown as dashed line arrows.

15 List all the pairs of classes that can communicate directly with each other. For each class, list all the methods that need to be included, based on this sequence diagram resource manager Res. Mgr. Win: UI :Worker:Skill:SkillLevel find worker find skill assign skill to worker find worker by name find skill by name [worker does not currently have skill] assign skill to worker Homework

16 Messages from an object to itself An object may, and frequently does, send a message to itself On a collaboration diagram you show a link from the object to itself, and messages pass along that link in the usual way On a sequence diagram, you show a message arrow from the object’s lifeline back to itself. In pure object oriented programming, –every function invocation is the result of a message, and –objects may send messages to themselves so often that an interaction diagram becomes cluttered You might choose to omit messages from an object to itself, counting such things as internal computation within the object.

17 Suppressing detailed behaviour It is often sensible to describe interaction at a higher level, rather than showing every message between every pair of objects. To do this we define a (full) sub-collaboration of a collaboration –Collaboration is a collection of objects and links between them –Sub-collaboration is a subset of the objects, together with the links connecting those objects.

18 Using a package to simplify a collaboration

19 Creation and deletion of objects The set of objects involved in an interaction is not always static; objects may be created and deleted during an interaction. Collaboration diagram –These show which objects are created and destroyed during an interaction by adding the constraints {new} {destroyed}. –If the object is both created and destroyed in the same interaction, it can be labelled {transit} Sequence diagram –These show an object being created by putting its object box part-way down the page, at the point it is created –Destruction of an object is shown by its activation ending with a large X.

20 Collaboration diagram

21 Sequence diagram

22 Timing The major advantage of sequence diagrams over collaboration diagrams is their ability to represent the passage of time graphically. So far we have let the diagram indicate only the relative ordering messages. Sometimes, however, the actual times are important. A system in which actual times are important is called a real-time systems.

23 Showing timing constraints on a sequence diagram

Essentials of state and activity diagram

25 So far we have discussed: How to describe the requirements of a system using use cases How to model the static structure of a system using a class model How to model objects interact to satisfy the requirements using interaction diagrams We have not discussed, how model an object’s “decision” about what to do when it receives a message.

26 Outline State Diagram Designing classes with state diagrams Activity diagram

27 State Diagrams Let us start with a very simple example in which an object receives a message and what it does depends on the values of its attributes and links. In our library system an object of class Copy may have a Boolean attribute onShelf which is intended to record whether the object describes a copy of a book –which is currently in the library, –or one which is currently on loan. The interface of a class Copy specifies that the object should be willing to accept the message borrow().

28 State diagram of class Copy The value of the copy’s attribute onShelf is important for understanding the behaviour of the object, –at level of what messages it sends after receiving message itself We can name two significantly different states of a Copy object –“on the shelf” and “on loan” We can record the messages that cause it to move between the states as the events that cause transition between states.

29 Unexpected messages In previous figure we have not shown arrows to represent –the receipt of message borrow() in state “on loan” or –the message return() in state “on shelf” Under normal circumstances, such messages should not arrive: if they do it’s a bug. So the code of class Copy will have to do something if these “wrong” messages do arrive In fact our convention is a departure from UML, which specifies that an event, such as the arrival of message, that does not trigger a transition is simply ignored

30 State, transitions, events The most important elements of a state diagram, namely: States –Shown as boxes with rounded corners Transitions between states –Shown as arrows Events that cause transitions between states –Shown by writing the message on the transition arrow Start marker –Shown as a black blob with an (unlabeled) arrow into the initial state of the diagram Stop marker –Shown by a black blob with a ring round it and means that the object has reached the end of its life.

31 Actions The state diagrams were useful for understanding how an object’s reaction to a message depends on its state. An object sending a message in response to being sent one itself –is an example of an action being an object’s reaction to an event. An event is something done to the object such as it being sent a message An action is something that the object does such as it sending a message

32 State diagram of class Copy with action Analysing the notation: –The slash (/) shows that what follows is an action –book followed by a dot identifies the object to which a message is being sent –returned(self) is an example of a message including a parameter, where self is reference to itself

33 State diagram of class Copy with - entry action - exit action We can show our intention directly, by writing the action inside the state, as a reaction to the special event (e.g entry or exit)

34 Guards Sometimes the occurrence of the same event in the same state may or may not cause a change of state, –depending on the exact values of the object’s attributes We can show this using the same conditional notation that is used in generic interaction diagrams Several actions in one diagram.

35 State diagram for class Book The borrowed() message cause a state change out of state borrowable –only if this is the last copy on the shelf; –otherwise, the book object remains borrowable.

36 Activity diagram Activity diagrams describe how activities are coordinated. –For example, an activity diagram may be used ( like an interaction diagram ) to show how an operation could be implemented An activity diagram is particularly useful –when you know that an operation has to achieve a number of different things, and –you want to model what the essential dependencies between them are, before you decide in what order to do them Activity diagrams are much better at showing this clearly than interaction diagrams.

37 At the UML semantics level, activity diagrams are state diagrams extended for convenience with some extra notation Elements of activity diagrams –Activity –Transition –Synchronization bar –Decision diamond –Start and stop markers

38 Business level activity diagram of the library

39 The main differences between activity diagrams and state diagrams: Activity diagrams do not normally include events Activity is intended to proceed, following the flow described by diagram, without getting stuck