3. CSE. Learning Goals. • Be able to draw and understand basic UML sequence
diagrams. • Be able to draw and understand basic UML activity diagrams.
CSE 70: Unified Modeling Language Sequence and Activity Diagrams Ingolf Krueger
Department of Computer Science & Engineering University of California, San Diego La Jolla, CA 92093-0114, USA
California Institute for Telecommunications and Information Technologies La Jolla, CA 92093-0405, USA
Learning Goals for Today
© Ingolf Krueger, 2010
CSE
2
Learning Goals
• Be able to draw and understand basic UML sequence diagrams.
• Be able to draw and understand basic UML activity diagrams.
© Ingolf Krueger, 2010
CSE
3
Unified Modeling Language (UML)
source: http://commons.wikimedia.org/wiki/File:UML_Diagrams.jpg © Ingolf Krueger, 2010
CSE
4
Basics Covered in CSE 70
Behavior State Machine
Structure Use case
Class Object
Interaction Overview
Sequence Activity
Component Composite Structure Deployment
Communication © Ingolf Krueger, 2010
Package CSE
5
Sequence Diagrams • Describe how multiple objects communicate/collaborate
• Useful to represent processes and their communication
• Express interaction scenarios of user stories
© Ingolf Krueger, 2010
CSE
6
Example: Chat System Classes
© Ingolf Krueger, 2010
CSE
7
Example: ChatServer Class in Java ChatSystem.java !
public class ChatSystem {! ... ! private ChatServer server; ! private ChatClientImp client1;! private ChatClientImp client2;! ... ! public static void main() {! server = new ChatServer(“my_server”);! client1 = new ChatClientImp(“max”);! client2 = new ChatClientImp(“barry”);! }! ...! }!! © Ingolf Krueger, 2010
CSE
8
How do server, client1 and client2 interact?
© Ingolf Krueger, 2010
CSE
9
Example: Sequence Diagram for User Sign On
object message/ method call lifeline
selfcall
activation
© Ingolf Krueger, 2010
CSE
10
Example: ChatServer Class in Java ChatServer.java !
public class ChatServer{! ...! public void store(String user) {...}! ...! public void sign_on(String user) {! store(user);! ...! }! ...! }!!
© Ingolf Krueger, 2010
CSE
11
Example: Sequence Diagram for Notify
© Ingolf Krueger, 2010
CSE
12
Example: Sequence Diagram for Sign Off
call return w/return value
© Ingolf Krueger, 2010
CSE
13
UML Activity Diagrams
© Ingolf Krueger, 2010
CSE
14
Activity Diagrams • Describe workflows/business processes
• Useful to represent execution sequences without showing the details of how the individual steps are implemented
• Express execution “flow” of user stories
• Bigger-picture view compared to sequence diagrams © Ingolf Krueger, 2010
CSE
15
Recall: Set up Conference User Story
Title: Set up conference Description: User marks a set of other users in their buddy list, then issues the “setup conference” command, then enters the name of the conference and optionally a description/purpose.
© Ingolf Krueger, 2010
CSE
16
Example: Activity Diagram for Set up Conference initial node activity final
action decision
flow merge © Ingolf Krueger, 2010
CSE
17
Expressing Parallel Actions
© Ingolf Krueger, 2010
CSE
18
User Signs On User Story
Title: User Signs On Description: User submits credentials to the server. Then, in parallel, the server logs the sign-on attempt, and saves the user name.
© Ingolf Krueger, 2010
CSE
19
Activity Diagrams: Fork and Join fork
join © Ingolf Krueger, 2010
CSE
20
What have you learned today?
© Ingolf Krueger, 2010
CSE
21
Learning Goals
• Be able to draw and understand basic UML sequence diagrams.
• Be able to draw and understand basic UML activity diagrams.
© Ingolf Krueger, 2010
CSE
22