Recent Changes - Search:

Software Engineering

This website demonstrates using wikis as teaching and learning tool.

The course instructor is also happy to share the teaching materials here with those who find it readable.

Modeling with UML - Part 2

A Software Engineering Lecture by Steven Choy

Lecture Overview: In this lecture, we will continue to learn UML modeling. We will have a look at the other three fundamental notations of UML: interaction diagrams, statechart diagrams, and activity diagrams.

Here is a short summary of what you have learned in Lecture 03 and Lecture 04.

  • Use case diagrams: Represent the functionality of the system from a user's point of view;
  • Class diagrams: Represents the structure of a system in terms of objects, their attributes, and relationships;
  • Interaction diagrams: Represent the system's behavior in terms of interactions among a set of objects;
  • Statechart diagrams: Represent the behavior of nontrivial objects;
  • Activity diagrams: Flow diagrams used to represent the data flow or the control flow through a system.

Reading: Chapter 2 of the textbook: Modeling with UML


Interaction Diagrams

Overview

  • Describe how groups of objects interact with each other for a use case
    • formalize the dynamic behavior of the system
    • visualize the communication among objects
  • Useful for identifying additional objects that participate in the use cases
  • Two types of interaction diagrams:
    • Sequence Diagrams
    • Collaboration Diagrams / Communication Diagram (UML 2.0)

Examples

Sequence diagram
One more example is Figure 2.3 of the textbook.
Collaboration diagram
One more example is Figure 2.36 of the textbook.

Sequence Diagrams

  • Details how operations are carried out within the use case
    • What messages are sent between objects
    • What the message sequence is
  • In the diagram,
    • Objects are listed horizontally from left to right
    • Message sequences (time order) are from top to bottom
Example: Product Redemption

Collaboration Diagrams

  • Known as "Communication Diagram" in UML 2.0
  • Depict the same information as sequence diagram
  • But emphasize on how objects are linked rather than when the messages are sent
  • Use dotted number scheme to represent the sequence of messages
Example: Product Redemption

Sequence Diagram vs Collaboration Diagram

  • What do you want to emphasize?
    • The sequence of messages ⇒ Sequence Diagram
    • How objects are linked together ⇒ Collaboration Diagram
  • Personally, I use sequence diagram more often
    • but it really depends on what information you're going to convey

statechart Diagram

Overview

  • Objects have state, which depends on the current activity
  • Statechart diagram is designed to describe
    • The possible states that an object can have
    • How an object transfer from one state to another
  • State: a particular set of values for an object
  • Given a state, a transition represents a future state the object can move to and the conditions associated with the change of state
  • Focuses on the transitions between states as a result of external events for an individual object

Examples

When to use Statechart Diagram?

  • You may not need to draw statechart diagram for every object that you have
  • Use it for those objects that have complex state transitions and you want to make it clear

Activity Diagram

Overview

  • A more fancy flowchart
  • A variant of statechart diagram
  • Focus on the flow of activities for a business process

Activity Diagram Examples

Example: Order Fulfillment

Notation

  • Initial Activity: starting point of the flow, denoted by a solid circle
  • Activity: represented by a rounded rectangle
  • Branch: the decision point, denoted by a diamond. Decision is based on the guard
  • Merge: represent the end of the conditional behaviour, started by a branch
  • Fork: represent the start of a concurrent activity
  • Join: represent the end of a concurrent activity
Please note Fork and Join must match!

Swimlanes

  • The previous activity diagram only shows us the activities involved, but can we tell who does the activities?
  • Swinlane depicts the responsible objects for particular activities
Swimlanes: Order Fulfillment Example

When to use Activity Diagram

  • Study the overall workflow of a business process
  • Analyze use cases
  • Model multi-threaded program (remember fork/join?)

Interaction vs Statechart vs Activity Diagram

Martin Fowler, author of UML Distilled, mentioned:

  • Interaction diagrams are good at describing the behaviour of several objects in a single use case
  • Statechart diagram is good at describing the behaviour of an object across several use cases
  • Activity diagrams are good at showing the flow of activity for several objects and use cases

Summary

Use case diagrams Represent the functionality of the system from a user's point of view
Class diagrams Represents the structure of a system in terms of objects, their attributes, and relationships
Interaction diagrams Represent the system's behavior in terms of interactions among a set of objects
Statechart diagrams Represent the behavior of nontrivial objects
Activity diagrams Flow diagrams used to represent the data flow or the control flow through a system

Diagram Organization

  • Complex system results in hundreds of use cases/classes/activities
  • Organize related elements into package
  • Package diagram is used for grouping related items together for ease of management and improve readability

Package Diagram Example

A Final Word

"Think before you draw, you may not need all types of UML diagrams for your software project. Use it wisely, don't overuse, though UML is great tool for software development."

Extra materials for studying Unified Modeling Language (UML)


UML Tools

  • UMLet 7.1 - Free UML Tool for Fast UML Diagrams: UMLet is an open-source UML tool: draw UML diagrams, export diagrams to eps, pdf, jpg, svg, and clipboard, share diagrams using Eclipse, and create new, custom UML elements. It runs stand-alone or as Eclipse plug-in on Windows, OS X and Linux.
  • Visual Paradigm for UML: Visual Paradigm for UML (VP-UML) is a powerful, cross-platform and yet the most easy-to-use visual UML modeling and CASE tool. VP-UML provides software developers the cutting edge development platform to build quality applications faster, better and cheaper!
  • StarUML - The Open Source UML/MDA Platform: It is an open source project to develop fast, flexible, extensible, featureful, and freely-available UML/MDA platform running on Win32 platform.
  • ArgoUML: It is the open source UML modeling tool and includes support for all standard UML 1.4 diagrams. It runs on any Java platform and is available in ten languages.
  • UMLGraph - Declarative Drawing of UML Diagrams: UMLGraph allows the declarative specification and drawing of UML class and sequence diagrams.

Thanks for Reading

If you would rather like to have this lecture note in printed format, please click the print action link in the top right corner.

If you find any problem in this lecture note, please feel free to tell Steven by steven@findaway.hk

Edit - History - Print - Recent Changes - Search
Page last modified on June 22, 2009, at 11:23 PM