knowledge-kitchen

UML Diagrams - A Standardized Visual Language for Software Design

Standardized ways of diagramming software systems.

  1. Overview
  2. Best practices
  3. Classes
  4. Use Cases
  5. Activities
  6. Sequences
  7. State Charts
  8. Conclusions

Overview

Concept

Primitive, standardized, easy-to-draw diagrams to quickly communicate software structure and behavior.

Types of diagrams

UML (Unified Modeling Language) provides for many types of diagrams, divided into two categories:

Structural Behavioral
Class diagrams Activity diagrams
Package diagrams Sequence diagrams
Object diagrams Use case diagrams
Component diagrams State diagrams
Deployment diagrams Communication diagrams
  Interaction diagrams
  Timing diagrams

Types of diagrams

We will explore just a few diagram types for example.

The book, “The Elements of UML Style”, by Scott W. Ambler is a good reference for more - we have pulled some key insights from it here.

Best Practices

Overview

Regardless of which diagram type, following best practices keeps diagrams understandable and avoids common pitfalls.

Avoid crossed lines

Don’t do this:

crossed lines

Avoid crossed lines

Do this:

crossed lines

Avoid diagonal and curved lines.

Don’t do this:

crossed lines

Avoid diagonal and curved lines.

Do this:

crossed lines

Use consistent sizes

Don’t do this:

crossed lines

Use consistent sizes

Do this:

crossed lines

Flow top-to-bottom, left-to-right

Don’t do this:

crossed lines

Flow top-to-bottom, left-to-right

Do this:

crossed lines

Classes

Concept

Used to display the attributes, methods, and interactions of object-oriented classes in code.

One Class

A single class:

UML class diagram

Multiple Classes

Relationships among classes, plus annotations, in a casual style:

UML class diagram

Use Cases

Concept

Used to indicate interactions between actors and the system.

Single actor

A single actor, a single system:

UML use case diagram

Multiple actors

Multiple actors, multiple systems:

UML use case diagram

Read more about the use of use cases in requirements engineering.

Activities

Concept

Flow charts often used to document a complex operation, the logic of one or more use cases, or any other process.

Example 1

UML activity diagram

From The Elements of UML Style:

In [this figure], you can see that the business process forks into two parallel streams, one where the person attends a presentation and another where he or she signs up and pays for courses. The process forks – the person performs these activities – and when both streams are complete, the process continues from there (in this case it simply ends).

Shapes

The basic shapes in an activity diagram are:

Sequences

Concept

Used to validate and work out the logic and completeness of a certain scenario, often a use case or a part of a use case.

These show the entire sequence of messages sent among the objects and systems involved in the scenario.

Example

UML sequence diagram

State Charts

Concept

Indicate the dynamic behavior of an entity based on its response to events, showing how the entity reacts to various events based on its current state.

Example

A seminar, partial lifecycle:

UML sequence diagram

Example

A seminar, complete lifecycle:

UML sequence diagram

Conclusions

Thank you. Bye.