UML 2.0 defines 14 types of diagrams, divided into 3 categories:

digraph {
	rankdir=RL
	node [shape=rectangle]
	A1,A2,A3,A4->B2
	B1,B2,B3,B4->C1
	B5,B6,B7,B8,B9,B10,B11->C2
	C1,C2->D1
 
	D1 [label="Diagram"]
	C1 [label="Behaviour Diagram"]
	C2 [label="Structure Diagram"]
	B1 [label="Activity Diagram"]
	B2 [label="Interaction Diagram"]
	B3 [label="State Machine Diagram"]
	B4 [label="Use Case Diagram"]
	B5 [label="Composite Structure Diagram"]
	B6 [label="Class Diagram"]
	B7 [label="Deployment Diagram"]
	B8 [label="Component Diagram"]
	B9 [label="Package Diagram"]
	B10 [label="Object Diagram"]
	B11 [label="Profile Diagram"]
	A1 [label="Communication Diagram"]
	A2 [label="Interaction Overview Diagram"]
	A3 [label="Sequence Diagram"]
	A4 [label="Timing Diagram"]
}

Use-case diagram (learn)

Use-case diagram (UML)

A use-case diagram shows the relation of actors to system functions, they can represent the stakeholders / users view of a system.

It consists of the elements:

  • System (UML Use-case)

    The system (boundary) is the boundary between the system and the users of the system.

    graph {
    	subgraph cluster0 {
    		label="System"
    		A
    	}
     
    	Actor [shape=star label="" xlabel="X"]
    	A--Actor
    }
    Link to original
  • Actor (UML Use-case)

    Actors interact with the system by using use cases (actors initiate execution of use case) and by being used by use cases (actors provide functionality for the execution of the use case). Actors represent roles that users / systems adopt.

    • Specific users can adopt and set aside multiple roles simultaneously.
    • Actors are not part of the system / they are outside of system boundaries.
    graph {
    	label="role of the users of the system"
    	A [shape=star label="" xlabel="A"]
    }
    Link to original
  • Use cases (UML Use-case)

    Use cases describe the functionality expected from the system under development, it provides tangible benefit for one or more actors that communicate with this use case. It is derived from the customer’s wishesw

    graph {
    	label="unit of functionality of the system"
    	A
    }
    Link to original
  • Association (UML Use-case)

    Associations connect Actors and use cases via solid lines. Every actor must communicate with at least one use case. An association is always binary and multiplicities may be specified.

    graph {
    	nodesep=0.8
     
    	subgraph cluster0 {
    		label = "Laboratory Assignment"
    		c [label="Conduct oral exam"]
    	}
     
    	c--a
    	c--s [label="1..3"]
     
    	a [shape=star label="" xlabel="Assistant"]
    	s [shape=star label="" xlabel="Student"]
    }
    Link to original
  • Generalisation (UML Use-case)

    Generalisation shows inheritance relationships between actors or use cases. Multiple inheritance is permitted, abstract actors are possible. Sub-actors can access all of their use cases plus those of the super-actor.

    digraph {
    	nodesep=2
     
    	B->A
    	D->C
     
    	D[shape=star label=B xlabel="Super-actor"]
    	C[shape=star label=A xlabel="Sub-actor"]
    }
    Link to original
  • Include relationship (UML Use-case)

    The include relationship, , is where the behaviour of one use case (included use case) is integrated in the behaviour of another use case (base use case).

    digraph {
    	layout=neato
    	splines=true
     
    	actor [shape=star label=""]
    	actor->A,B [arrowhead=none]
    	A->B [label=" «include»"]
    }
    Link to original
  • Extend relationship (UML Use-case)

    The extend relationship, , is where the behaviour of one use case (extending use case) may be integrated in the behaviour of another use case (base use case) but does not have to. Both use cases may be executed independently of each other.

    • decides if is executed.
    • Extension points define at which point the behaviour is integrated.
    • Conditions define under which circumstances the behaviour is integrated.
    • Multiple extension points may be specified.
    • Extension points are written directly on the use case.
    digraph {
    	layout=neato
    	splines=true
     
    	actor [shape=star label=""]
    	actor->A,B [arrowhead=none]
    	B->A [label=" «extend»"]
    }
    Link to original
Link to original

Class Diagram (learn)

Class diagram (UML)

A class diagram shows the static class structure, they are used when developing an object-oriented system model to show the classes in a system and the associations between these classes.

It consists of:

  • Class (UML Class)

    An object class (or just class) which can be thought of as a general definition of one kind of system object.

      	graph {
      		node [shape=record]
      		Course
      		CourseCoarse [label = <{<b>Course</b> | name<br align="left"/>semester<br align="left"/>hours<br align="left"/>|getCredits()<br align="left"/>getLecturer()<br align="left"/>getGPA()<br align="left"/>}>]
      		CourseFine [label = <{<b>Course</b> | + name: String<br align="left"/>+ semester: SemesterType<br align="left"/>- hours: int<br align="left"/>- /credits: int<br align="left"/>|+ getCredits(): int<br align="left"/>+ getLecturer(): Lecturer<br align="left"/>+ getGPA(): float<br align="left"/>+ getHours(): float<br align="left"/>+ setHours(hours: float): void<br align="left"/>}>]
      	}
    Link to original
  • Object (UML Class)

    Objects are instances of classes.

    graph {
    	node [shape=record]
     
    	Class [label=<{<b>User</b> <br align="left"/>| + ID: int<br align="left"/>+ name: String<br align="left"/>+ address: String<br align="left"/>}>]
     
    	Object [label=<{<b>deez:User</b> <br align="left"/>| ID = 0044<br align="left"/>name = "deez"<br align="left"/>address = "123 Fake Street"<br align="left"/>}>]
    }

    Attribute (UML Class)

    Attributes define the structural characteristics of a class, each instance / object has a different value.

    Link to original

    Operation (UML Class)

    An operation is the behaviour of a class, it is identical for all objects of a class, they are not depicted in the object diagram.

    Link to original

    Link to original
  • Attribute Syntax (UML Class)

    Each attribute follows a certain syntax which is built up using the following structure:

    1. Visibility: who is permitted to access the attribute
      • +: public / everyone
      • -: private / only the object itself
      • #: protected / class itself and sub-classes
      • ~: package / classes that are in the same package
    2. Derived: / is specified if the attribute value is derived from other attributes
    3. Name: name of the attribute
    4. Type: it may be one of:
      • Another user-defined class
      • Predefined primitive data type (Boolean, Integer, String)
      • User-defined primitive data type: «primitive»
        	graph {
        		node[shape=record]
        		Float [label=<{«primitive» <br align="center"/><b>Float</b> <br align="center"/>| round(): void<br align="left"/>}>]
        	}
      • Composite data type: «datatype»
        	graph {
        		node[shape=record]
        		Float [label=<{«datatype» <br align="center"/><b>Date</b> <br align="center"/>| day<br align="left"/>month<br align="left"/>year<br align="left"/>}>]
        	}
      • Enumeration: «enumeration»
        	graph {
        		node[shape=record]
        		Float [label=<{«enumeration» <br align="center"/><b>AcademicDegree</b> <br align="center"/>| bachelor<br align="left"/>master<br align="left"/>phd<br align="left"/>}>]
        	}
    5. Multiplicity: number of values an attribute may contain
      • By default, we take it to be .
      • Notation is .
      • No upper limit may be indicated by or .
    6. Default value: used if the attribute value is not set explicitly by the user
    7. Properties: additional restrictions on attributes
      • Predefined properties that may be used:
        • {readOnly}: value cannot be changed
        • {unique}: no duplicates permitted
        • {non-unique}: duplicated permitted
        • {ordered}: fixed order of the values
        • {unordered}: no fixed order of the values
      • Common attribute specifications:
        • Set: {unordered, unique}
        • Multi-set: {unordered, non-unique}
        • Ordered set: {ordered, unique}
        • List: {ordered, non-unique}
    Link to original
  • Operation Syntax (UML Class)

    Each operation follows a certain syntax which is built up using the following structure:

    1. Visibility: see Attribute Syntax (UML Class)
    2. Name: see Attribute Syntax (UML Class)
    3. Parameter: similar notation to attributes: In addition, a direction may be specified:
      • in: input parameter When the operation is used, a value is expected from this parameter.
      • out: output parameter After the execution of the operation, the parameter has adopted a new value.
      • inout: combined input / output parameter
    4. Type: type of the return value
    Link to original
  • Association (UML Class)

    An association: link between classes that indicates that there is some relationship between these classes.

    	graph {
    		rankdir=LR
    		node[shape=rectangle]
    		Lecturer--Course
    	}
    Link to original
  • Binary Association (UML Class)

    A binary association is an association between two classes where an instance of one class must know about the other in order to perform its work.

    • Role names and multiplicities are labelled at both ends.
    • In uni-directional associations, role name at the start of the arrow is optional.
    • Can be used to formalise requirements such as “each professor may coach a set of students, and each student is coached by exactly one professor”

    Multiplicity (UML)

    The multiplicity is the number of objects that may be associated with exactly one object of the opposite side.

    UML NotationMeaning
    any number of objects (incl. zero)
    at least one object
    exactly one object
    exactly objects
    at least and at most objects
    graph {
    	rankdir=LR
    	node [shape=rectangle]
    	Lecturer--Assignment [taillabel="1" label="issues" headlabel="*"]
    }
    graph {
    	rankdir=LR
    	node [shape=rectangle]
    	Lecturer--Assignment [taillabel="1..*" label="gives" headlabel="1..*"]
    }
    Link to original

    Role (UML Class)

    The role describes the way in which an object is involved in an association relationship.

    Link to original

    Link to original
  • Unary Association (UML Class)

    A unary association is between a class and itself.

    graph {
    	node[shape=rectangle]
    	Person--Person [taillabel="0..1" label="  is married to"]
    	Employee--Employee [taillabel="+manager 1" headlabel="+staff 1..*" label="  manages"]
    }
    Link to original
  • Association Class (UML Class)

    An association class allows us to assign attributes to the relationship between classes rather than to a class itself.

    This is necessary when we are modelling n:m associations.

    Link to original
  • Aggregation (UML Class)

    An aggregation is a special form of association used to express that a class is part of another class, properties of the aggregation association include:

    • transitive: if is part of and is part of , is also part of
    • asymmetric: it is not possible for to be part of and to be part of at the same time

    There are two types:

    1. Shared Aggregation (UML Class)

      A shared aggregation expresses “a weak belonging of the parts to a whole” where parts also exist independently of the whole. Multiplicity at the aggregating end may be hence one element can be part of multiple other element at the same time. Syntax is a hollow diamond at the aggregating end.

      For example, take that:

      • a Student is part of LabClass
      • a Course is part of StudyProgram

      Link to original
    2. Composition (UML Class)

      A composition is an existence dependency between the composite object and its parts. One part can only be contained in at most one composite object at one specific point in time. Multiplicity at aggregating end is at maximum 1, the composite objects form a tree.

      If the composite object is deleted, its parts are also deleted. Syntax: solid diamond at the aggregating end.

      For example, a Beamer is part of LectureHall which is part of Building.

      Link to original
    Link to original
  • Generalisation (UML Class)

    A generalisation is where:

    • characteristics (attrs / ops), associations, and aggregations that are specified for the super-class are passed on to its sub-classes
    • every instance of a sub-class is at the same time an instance of the super-class
    • sub-class inherits all characteristics, associations, and aggregations of the super-class except private ones
    • sub-class may have further characteristics, associations, and aggregations Generalisations can also be transitive.

    UML allows multiple inheritance, so a class may have multiple super-classes.

    Link to original
Link to original

Object Diagram

Object diagram (UML)

An object diagram is the same as the Class diagram (UML) but only using class instances, i.e. objects.

Link to original

State Diagram

State diagram (UML)

A state diagram shows the states of objects in a particular class.

Link to original

Sequence Diagram (learn)

Sequence diagram (UML)

A sequence diagram shows an object message passing structure, it is a two-dimensional diagram. It consists of:

  • horizontal axis: involved interaction partners
  • vertical axis: chronological order of the interaction

Interaction (UML Sequence)

An interaction is a sequence of event specifications.

Link to original

Interaction Partners (UML Sequence)

Interaction partners are depicted as lifelines.

  • The head of the lifeline is a rectangle that contains the expression roleName:Class, roles are a more general concept than objects and objects can take on different roles over their lifetime.
  • The body of the lifeline is a vertical (usually dashed) line which represents the life time of the object associated with it.

Link to original

Messages

Message (UML Sequence)

A message is defined via a send and receive event, it is used to visualise when an Interaction Partners (UML Sequence) executes some behaviour.

There are several different types of message we need to know about:

  • Synchronous message (UML Sequence)

    Synchronous message: sender waits until it has received a response message before continuing. Syntax is msg(...parameters).

    Link to original
  • Asynchronous message (UML Sequence)

    Asynchronous message: sender continues without waiting for a response message. Syntax is msg(...parameters).

    Link to original
  • Response message (UML Sequence)

    Response message: may be omitted if the content and location are obvious. Syntax is attribute = msg(...parameters): return value.

    Link to original
  • Found Message (UML Sequence)

    Found message: sender of a message is unknown or not relevant.

    Link to original
  • Lost Message (UML Sequence)

    Lost message: receiver of a message is unknown or not relevant.

    Link to original
  • Time-consuming Message (UML Sequence)

    Time-consuming message: a message with a set duration. Usually we assume messages are transmitted with no loss of time, we express time elapses between the send and receipt of a message.

    Link to original
  • Object Creation (UML Sequence)

    Object creation is represented by a dashed arrow with an arrowhead pointing to the head of the lifeline of the object to be created. We use the keyword new.

    Link to original
  • Object Destruction (UML Sequence)

    Object destruction is indicated by a large cross at the end of the lifeline.

    Link to original
Link to original

Combined Fragments

Combined Fragments (UML Sequence)

We can use combined fragments to model various control structures.

There are three categories of types of fragments:

  • Branches and loops: alt, opt, loop, break
  • Concurrency and order: seq, strict, par, critical
  • Filters and assertions: ignore, consider, assert, neg

The types of fragments are:

  • Alt Fragment (UML Sequence)

    alt: to model alternative sequences, similar to a switch case.

    • Guards are used to select the one path to be executed. They are modelled in square brackets. We may use [else] to signify any other case if other guards fail.
    • Guards must be disjoint to avoid in deterministic behaviour.

    Link to original
  • Opt Fragment (UML Sequence)

    opt: to model optional sequence actual execution at runtime is dependent on the guard.

    • Exactly one operand.
    • Similar to if without else branch.
    • Equivalent to Alt Fragment (UML Sequence) with two operands where one is empty.

    Link to original
  • Loop Fragment (UML Sequence)

    loop: to express that a sequence is to be executed repeatedly.

    • Exactly one operand.
    • Keyword is followed by minimal / maximal number of iterations. (min..max) or (min, max) Examples of equivalent notation:
      • loop(3,8) = loop(3..8)
      • loop(8,8) = loop(8)
      • loop = loop(*) = loop(0, *)
    • Guard is evaluated as soon as the minimum number of iterations has taken place, then checked also for each iteration within the limits. If the guard evaluates to false, the execution of the loop is terminated.

    Link to original
  • Break Fragment (UML Sequence)

    break: simple form of exception handling.

    • Exactly one operand with a guard.
    • If the guard is true:
      1. Interactions within the operand are executed.
      2. Remaining operations of surrounding fragment are omitted.
      3. Interaction continues in next higher lever fragment.

    Link to original
  • Strict Fragment (UML Sequence)

    strict: sequential interaction with order

    • Order of event occurrences on different lifelines between different operands is significant.
    • Messages in an operand that is higher up on the vertical axis are always exchanged before the messages in an operand that is lower down on the vertical axis.

    Link to original

In addition, we may apply:

  • Coregion (UML Sequence)

    A coregion is used to model concurrent events of a single lifeline.

    • The order of event occurrences within a coregion is not restricted.
    • Area of the lifeline to be covered by the coregion is marked by square brackets rotated by 90 degrees.

    Link to original
  • Interaction Reference (UML Sequence)

    An interaction reference integrates one sequence diagram into another.

    Link to original
  • Gate (UML Sequence)

    A gate allows you to send and receive messages beyond the boundaries of the interaction fragment.

    Link to original
  • Time Constraints (UML Sequence)

    We may specify time constraints such as:

    • The point in time for event occurrence.
      • Relative: after(5sec)
      • Absolute: at(12.00)
    • Time period between two events:
      • {lower..upper}

    Link to original
Link to original

Link to original

Collaboration Diagram

Collaboration diagram (UML)

A collaboration diagram is the same as a Sequence diagram (UML) but is also shows context, i.e. objects and their relationships.

Link to original

Activity Diagram

Activity diagram (UML)

An activity diagram shows the sequential flow of activities.

Link to original

Component Diagram

Component diagram (UML)

A component diagram shows the code structure.

Link to original

Deployment Diagram

Deployment diagram (UML)

A deployment diagram is the mapping of software to hardware.

Link to original

State Machine Diagram (learn)

State Machine Diagram (UML)

A state machine diagram is used to:

  • Model the possible states of a system or object
  • Show how the state transitions occur as a consequence of events
  • Show what behaviour the system or object exhibits in each state

There are multiple components to a state machine diagram:

  • State (UML State Machine)

    State is the nodes of the state diagram.

    • When a state is active, the object is in that state.
    • All internal activities specified in the current state can be executed.
    • An activity can consist of multiple actions.

    Activity specifications:

    • entry / Activity(...): executed when the object enters the state
    • exit / Activity(...): executed when the object exits the state
    • do / Activity(...): executed while the object remains in this state

    Link to original
  • Transition (UML State Machine)

    A transition changes from one state to another.

    The syntax used is as follows:

    1. Event (trigger): exogenous stimulus, can trigger state transition
    2. Guard (condition): boolean expression
      • if the event occurs, guard is checked
      • if guard is true:
        • any activities in current state are terminated
        • relevant exit activity is executed
        • transition takes place
      • if guard is false:
        • no state transition takes place, event is discarded
    3. Activity (effect): sequence of actions executed during the state transition

    There are two types of transition:

    Link to original
  • Event (UML State Machine)

    There are different types of events we need to handle in a state diagram:

    • Signal event: receipt of a signal e.g. rightmousedown, sendSMS(message)

    • Call event: operation call e.g. occupy(user, lectureHall), register(exam)

    • Time event: time-based state transition e.g. after(5 seconds) or when(time==16:00)

    • Any receive event: occurs when any event occurs that does not trigger another transition from the active state e.g. keyword = all

    • Completion event: generated automatically when everything to be done in the current state is completed

    • Change event: permanently checking whether a condition becomes true e.g. when(x,y), after(90min)

      Below is a comparison between a change event and a guard:

    Link to original
  • Initial State (UML State Machine)

    The initial state is the start of a state machine diagram.

    • It is a pseudo-state.
    • No incoming edges.
    • If there is more than 1 outgoing edge, guards must be mutually exclusive and cover all possible cases to ensure that exactly one target state is reached.
    • If initial state becomes active, the object immediately switches to the next state.
    • No events allowed on the outgoing edges.

    Link to original
  • Final State (UML State Machine)

    The final state is a real state and marks the end of the sequence of states. Object can remain in a final state forever.

    Link to original
  • Terminate Node (UML State Machine)

    The terminate node is a pseudo-state that terminates the state machine. The modelled object ceases to exist.

    Link to original
  • Decision Node (UML State Machine)

    A decision node is a pseudo-state and is used to model alternative transitions.

    Link to original
  • Parallelisation Node (UML State Machine)

    A parallelisation node is a pseudo-state that splits control flow into multiple concurrent flows. There is one incoming edge and one or more outgoing.

    Link to original
  • Synchronisation Node (UML State Machine)

    A synchronisation node is a pseudo-state that merges multiple concurrent flows. There is one or more incoming edge and one outgoing edge.

    Link to original
Link to original