UML Diagrams: Class, Object, Use Case, State, Component, Sequence, and Activity

Class Diagrams

Class diagrams show classes, interfaces, and collaborations, along with their relationships. They can include class notes and restrictions, and can contain packages to group elements. Instances can be placed in class diagrams to show the type of an instance.

Object Diagrams

UML object diagrams display static aspects of a system’s construction. Interaction diagrams show dynamic aspects, including the occurrence of messages between objects. Object diagrams contain instances of elements found in class diagrams, expressing the static interaction of collaborating objects.

Interactions

In any system, objects interact by passing messages. An interaction is a set of messages exchanged by a set of objects within a specific context.

Use Case Diagrams

Use case diagrams show use cases, actors, and their relationships. They cover the static view of use cases and are important for modeling and organizing behavior.

State Diagrams

State diagrams show states, transitions, events, and activities. They cover the dynamic view of a system and are important for modeling the behavior of an interface, class, or collaboration.

Component Diagrams

Component diagrams show the organization and dependencies of components. They relate to class diagrams, as a component usually contains classes, interfaces, or collaborations.

Architecture

Developing a software system requires different perspectives. Different users (end users, analysts, developers, integrators, project managers) have different views of the project, depending on their needs at each moment. The architecture involves significant decisions about:

  • System organization
  • Selection of structural elements and interfaces
  • Behavior and collaboration of components
  • Composition of structural elements
  • Architectural style

Sequence Diagrams

Sequence diagrams highlight the temporal ordering of messages. They show objects involved in an interaction along the x-axis, with the object initiating the interaction on the left. Messages are placed below, in order of succession, showing the flow of control over time.

Activity Diagrams

Activity diagrams show flows of activities. An activity is an atomic action within a state. Activities produce actions, which are atomic computations that change the system state or return a value. Actions include operations, sending signals, creating or destroying objects, and simple calculations. Activity diagrams show activities and transitions.

Transitions

When an action or activity is complete, control passes to the next state. Transitions show the path from one state to the next. In UML, a transition is represented by a line.

Bifurcation

Sequential transitions are common, but sometimes a fork is needed to model control flow. A fork specifies alternative paths, chosen based on a boolean expression. A bifurcation is represented by a diamond. Each output transition has a boolean expression, evaluated upon entering the bifurcation. Output transitions should not overlap but should cover all possibilities.

Division and Union

Sequential transitions and bifurcations are common in activity diagrams. However, concurrent flows are also possible, especially when modeling business workflows. UML uses a synchronization bar to specify the division and union of control flows. A synchronization bar is represented by a horizontal or vertical line.