Use Case Diagrams

Content

A use case diagram always starts with @start-ucd, ends with @end-ucd and requires to put a title in quotation marks right after the start tag. In second place, the package can be declared with the keyword rootPackage. The default package is “RootElement” and if this package is to be used, the package cansimply be omitted.

@start-ucd "My Title"
rootPackage RootElement
@end-ucd

Order of Elements

The ordering of elements is restricted by their type: First, all actors are specified. Second, the systems are defined. Use cases are located in systems. Last, the relationships between elements are given.

Actors

Actors are defined with the keyword act (for actor) and need a unique identifier that is given directly after the keyword.

act NameActor

A more extensive name can be assigned by writing the name in quotes after the keyword. As with the diagram title, an alias might also be given via the keyword as.

The type of the actor can be specified by assigning a role to it. This form of specification is introduced with the keyword role and the corresponding attribute in square brackets. Available roles are system and human.

act ticket booth role[system]
act visitor role[human]

Systems

A system is defined with the keyword sys followed by curly brackets. The curly brackets contain the use cases. The name of the system is between the keyword and the opening bracket. All use cases and their connections have to be described within the definition of the system.

sys BspSystem{
    uc UseCase
}

Use Cases

A use case is defined by the keyword uc (for use case) and a unique id.

uc UseCaseName

This id can not contain spaces except if the name is put in quotation marks.

uc "Name Use Case"

For such names in quotation marks, an alias may be given with the keyword as. To do so, the long name is written behind the keyword as.

uc Long as "Long Name Use Case"

Associations

Associations are defined between use cases and actors. They are located outside of the system. An association starts with the keyword iac (interacts). Afterwards the actor and the use case are given in that order in brackets separated by a comma.

act Person
sys Testsystem {
    uc UseCase
}
iac(Person,UseCase)

Cardinalities

Interactions can be specified further by cardinalities. These are specified behind the operand in square brackets. The order of operands indicates which attribute corresponds to which operand. Cardinalities are introduced with the keyword card.

Cardinalities are seperated by double colons. It is not possible to skip cardinalities, the default value is 0..1.

act Person
sys Testsystem{
    uc Label
    uc Multiplicity
    }
iac AssociationName (Person,Label)
iac AssociationName (Person,Multiplicity) card[2:*]

Generalizations

Generalizations start with the keyword isa followed by the participants given as a comma separated list in brackets. The specific element is given first, the general element is given second. Generalizations between use cases are located inside the system. Generalizations between actors are located outside of the system.

act Baby
act Mother
isa (Baby,Mother)

Relationships between Use Cases

Include relationships are defined by the keyword inc followed by the participants given as comma separated list in brackets. The including use case is the first one, the included use case the second one.

Extend relationships are defined by the keyword ext followed by the participants given as comma separated list in brackets. The first use case defines the extending use case. The second use case is the extended use case.

uc information
uc map
uc tour

inc (information, map)
ext (tour, information)

Extension Points

Extension Points can be defined with the keyword ep and an identifier, following the definition of a use case. The condition for the extension is optional and can be given with the keyword cond followed by the quoted condition in square brackets.

uc seeAnimal {
    ep Feeding
}
uc "watch the feeding" as Feeding
ext (Feeding, seeAnimal) ep[Feeding] cond["Visitor!=CareTaker"]

Notes

Notes can be given for actors, systems and use cases. They start with the keyword note followed by the comment in quotation marks. Actors can have a note at the end of their definition.

act Animal note "Some comment"

Systems can have a note after their name if there are no use cases contained, or as first entry after the curly bracket if there are use cases contained.

sys Zoo {
    note "Some comment"
    uc Visit
}
sys Accounting note "Some other comment"

Examples

Example Use Case Diagram
@start-ucd "useCase"

rootElement RootElement

act Person
act Vet
act Zookeeper
act Animal

sys Zoo {
	uc examine
	uc checkVitals
}

isa (Zookeeper, Person)
isa (Vet, Person)
inc (checkVitals, examine)
iac (Animal, examine) card[0..1 :0..1]
iac (Vet, examine) card[0..* :0..1]

@end-ucd