System Modeling and UML Diagrams
System Modeling and UML Diagrams
oSystem modeling has now come to mean representing a system using some kind of graphical
notation, which is now almost always based on notations in the Unified Modeling Language
(UML).
oSystem modelling helps the analyst to understand the functionality of the system and models
are used to communicate with customers.
o Models of the new system are used during requirements engineering to help explain
the proposed requirements to other system stakeholders. Engineers use these models
to discuss design proposals and to document the system for implementation.
oAn interaction perspective, where you model the interactions between a system and its
environment, or between the components of a system.
oA structural perspective, where you model the organization of a system or the structure of the
data that is processed by the system.
oA behavioral perspective, where you model the dynamic behavior of the system and how it
responds to events.
o Social and organisational concerns may affect the decision on where to position system
boundaries.
o Architectural models show the system and its relationship with other systems.
The position of the system boundary has a profound effect on the system requirements.
o Use case diagrams and sequence diagrams may be used for interaction modelling.
▪Actors
(who interacts with the system?)
▪ Professor
▪Use cases
(what can the actors do?)
▪ Query student data
▪ Issue certificate
▪ Announce exam
4
Actor
▪Actors interact with the system …
▪ by using use cases,
i.e., the actors initiate the execution of use cases.
▪ by being used by use cases,
i.e., the actors provide functionality for the execution of use cases.
▪Actors represent roles that users adopt.
▪ Specific users can adopt and set aside multiple roles simultaneously.
▪Actors are not part of the system, i.e., they are outside of the system boundaries.
▪Alternative notations:
6
Actor
▪Human Human
▪ E.g., Student, Professor Primary
Active
▪Non-human
▪ E.g., E-Mail Server Human
Secondary
▪Primary: has the main benefit of the execution of the use case Active
▪Secondary: receives no direct benefit
▪Active: initiates the execution of the use case
Human
▪Passive: provides functionality for the execution of the use case Primary
Active
▪Example: Non-human
Secondary
Passive
8
Relationships between Use Cases and Actors
▪Actors are connected with use cases via solid lines (associations).
▪Every actor must communicate with at least one use case.
▪An association is always binary.
▪Multiplicities may be specified.
9
8
Relationships between Use Cases
«inlcude» - Relationship
▪The behavior of one use case (included use case) is integrated in the behavior of another use
case (base use case)
10
Relationships between Use Cases
«extend» - Relationship
▪The behavior of one use case (extending use case) may be integrated in the behavior of another use
case (base use case) but does not have to.
▪Both use cases may also be executed independently of each other.
11
Relationships between Use Cases
«extend» - Relationship: Extension Points
▪Example:
12
Relationships between Use Cases
Generalization of Use Cases
▪Example:
13
Description of Use Cases - Example
▪ Name: Reserve lecture hall
▪ Short description: An employee reserves a lecture hall at the university for an event.
▪ System state in the event of an error: The employee has not reserved a lecture hall.
▪ Actors: Employee
(6’) Employee selects alternative lecture hall and confirms the reservation.
16
Best Practices
«include»
17
Best Practices
▪Use case diagrams do not model processes/workflows!
21
Best Practices
▪Actors are not part of the system, hence, they are positioned outside the system boundaries!
22
Best Practices
▪Many small use cases that have the same objective may be grouped to form one use case
✓
24
2.2 Sequence diagrams
oSequence diagrams are part of the UML and are used to model the interactions between the
actors and the objects within a system.
oA sequence diagram shows the sequence of interactions that take place during a particular use
case or use case instance.
oThe objects and actors involved are listed along the top of the diagram, with a dotted line
drawn vertically from these.
27
Interaction Partners
▪Interaction partners are depicted as lifelines
▪Head of the lifeline
▪ Rectangle that contains the expression roleName:Class
▪ Roles are a more general concept than objects
▪ Object can take on different roles over its lifetime
28
Exchanging Messages
▪Interaction: sequence of events
▪Message is defined via send event and receive event
▪Execution specification
▪ Continuous bar
▪ Used to visualize when an interaction partner executes some behavior
29
Messages
▪Synchronous message
▪ Sender waits until it has received a response message
before continuing
▪ Syntax of message name: msg(par1,par2)
▪ msg: the name of the message
▪ par: parameters separated by commas
▪Asynchronous message
▪ Sender continues without waiting for a response
message
▪ Syntax of message name: msg(par1,par2)
▪Response message
▪ May be omitted if content and location are obvious
▪ Syntax: att=msg(par1,par2):val
▪ att: the return value can optionally be assigned to a variable
▪ msg: the name of the message
▪ par: parameters separated by commas
▪ val: return value
30
Combined Fragments
▪Model various control structures
▪12 predefined types of operators Combined Fragment
Operator
Operand
Operand
Operand
31
alt Fragment
▪To model alternative sequences
▪Similar to switch statement in Java
▪Guards are used to select the one path to be executed
▪Guards
▪ Modeled in square brackets
▪ default: true
▪ predefined: [else]
▪Multiple operands
▪Guards have to be disjoint to avoid indeterministic
behavior
32
opt Fragment
▪To model an optional sequence
▪Actual execution at runtime is dependent on the guard
▪Exactly one operand
▪Similar to if statement without else branch
▪equivalent to alt fragment with two operands, one of
which is empty
33
loop Fragment
▪To express that a sequence is to be executed repeatedly
▪Exactly one operand
▪Keyword loop followed by the minimal/maximal number of iterations (min..max) or (min,max)
▪ default: (*) .. no upper limit
▪Guard
▪ Evaluated as soon as the minimum number of iterations has taken place
▪ Checked for each iteration within the (min,max) limits
▪ If the guard evaluates to false, the execution of the loop is terminated
Max
Min
Guard Notation alternatives:
loop is executed
at least once, loop(3,8) = loop(3..8)
then as long as loop(8,8) = loop (8)
a<1 is true loop = loop (*) = loop(0,*)
34
break Fragment
▪Simple form of exception handling
▪Exactly one operand with a guard
▪If the guard is true:
▪ Interactions within this operand are executed
▪ Remaining operations of the surrounding
fragment are omitted
▪ Interaction continues in the next higher
level fragment
▪ Different behavior than opt fragment
35
loop and break Fragment - Example
36
3- Structural models
o Structural models of software display the organization of a system in terms of the
components that make up that system and their relationships.
o Structural models may be static models, which show the structure of the system design, or
dynamic models, which show the organization of the system when it is executing.
o You create structural models of a system when you are discussing and designing the system
architecture.
o An object class can be thought of as a general definition of one kind of system object.
o An association is a link between classes that indicates that there is some relationship between
these classes.
o When you are developing models during the early stages of the software engineering process,
objects represent something in the real world, such as a patient, a prescription, doctor, etc.
Class name
Attributes
Operations
39
From Object to Class
▪Individuals of a system often have identical characteristics and behavior
Class
▪A class is a construction plan for a set of similar objects of a system
40
3.2 Aggregation
▪Aggregation means that one object (the whole) is composed of other objects (the parts).
▪To define aggregation, a diamond shape is added to the link next to the class that represents
the whole
41
3.3 Generalization
▪Characteristics (attributes and operations), associations, and
aggregations that are specified for a general class
(superclass) are passed on to its subclasses. Superclass
42
Generalization – Abstract Class
▪Used to highlight common characteristics of their subclasses.
▪Used to ensure that there are no direct instances of the superclass.
▪Only its non-abstract subclasses can be instantiated.
▪Useful in the context of generalization relationships.
▪Notation: keyword {abstract} or class name in italic font.
No Person-object possible
43
Generalization – Multiple Inheritance
▪UML allows multiple inheritance.
▪A class may have multiple superclasses.
▪Example:
44
With and Without Generalization
45
Creating a Class Diagram
▪Not possible to completely extract classes, attributes and associations from a natural
language text automatically.
▪Guidelines
▪ Nouns often indicate classes
▪ Adjectives indicate attribute values
▪ Verbs indicate operations
▪Example: The library management system stores users with their unique ID, name and
address as well as books with their title, author and ISBN number. Ann Foster wants to use
the library.
46
Example – University Information System
▪A university consists of multiple faculties which are composed of various institutes. Each
faculty and each institute has a name. An address is known for each institute.
▪Each faculty is led by a dean, who is an employee of the university.
▪The total number of employees is known. Employees have a social security number, a
name, and an email address. There is a distinction between research and administrative
personnel.
▪Research associates are assigned to at least one institute. The field of study of each
research associate is known. Furthermore, research associates can be involved in projects
for a certain number of hours, and the name, starting date, and end date of the projects
are known. Some research associates hold courses. Then they are called lecturers.
▪Courses have a unique number (ID), a name, and a weekly duration in hours.
47
Example – Step 1: Identifying Classes
We model the system „University“
48
Example – Step 2: Identifying the Attributes
▪A university consists of multiple faculties which are composed of various institutes.
Each faculty and each institute has a name. An address is known for each institute.
▪Each faculty is led by a dean, who is an employee of the university.
▪The total number of employees is known. Employees have a social security
number, a name, and an email address. There is a distinction between research
and administrative personnel.
▪Research associates are assigned to at least one institute. The field of study of each
research associate is known. Furthermore, research associates can be involved in
projects for a certain number of hours, and the name, starting date, and end date
of the projects are known. Some research associates hold courses. Then they are
called lecturers.
▪Courses have a unique number (ID), a name, and a weekly duration in hours.
49
Example – Step 3: Identifying Relationships
▪Three kinds of relationships:
▪ Association Abstract, i.e., no other types
of employees
▪ Generalization
▪ Aggregation
▪Indication of a generalization
▪“There is a distinction between research
and administrative personnel.”
▪“Some research associates hold courses. Then they are called
lecturers.”
50
Example – Step 3: Identifying Relationships
▪“A university consists of multiple faculties which are composed of various institutes.”
51
Example – Step 3: Identifying Relationships
▪“Each faculty is led by a dean, who is an employee of the university”
52
Example – Step 3: Identifying Relationships
▪“Research associates are assigned to at least one institute.”
53
Example – Step 3: Identifying Relationships
▪“Furthermore, research associates can be involved in projects for a certain number of hours.”
54
Example – Step 3: Identifying Relationships
▪“Some research associates hold courses. Then they are called lecturers.”
55
Example – Complete Class Diagram
56
4- Behavioral models
Behavioral models are models of the dynamic behavior of a system as it is executing. They show
what happens or what is supposed to happen when a system responds to a stimulus from its
environment.
You can think of these stimuli as being of two types:
◦ Data Some data arrives that has to be processed by the system.
◦ Events Some event happens that triggers system processing. Events may have associated data, although
this is not always the case.
o Data-driven models show the sequence of actions involved in processing input data and
generating an associated output.
o They are particularly useful during the analysis of requirements as they can be used to show
end-to-end processing in a system.
61
Edges
▪Connect activities and actions to one another
▪Express the execution order Control flow
▪Types
▪ Control flow edges
▪ Define the order between nodes
▪ Object flow edges
▪ Used to exchange data or objects
▪ Express a data/causal dependency between nodes
Object flow
▪Guard (condition)
▪ Control and object flow only continue if
guards in square brackets
evaluate to true
62
Beginning and Termination of Activities
▪Initial node
▪ Starts the execution of an activity
▪ Provides tokens at all outgoing edges
▪ Keeps tokens until the successive nodes accept them
▪ Multiple initial nodes to model concurrency
▪Decision behavior
▪ Specify behavior that is necessary for the evaluation of the guards
▪ Execution must not have side effects
64
Alternative Paths – Merge Node
▪To bring alternative sub-paths together
▪Passes token to the next node
65
Example: Alternative Paths
66
4.2 Event-driven modeling
o Real-time systems are often event-driven, with minimal data processing. For example, a
landline phone switching system responds to events such as ‘receiver off hook’ by generating a
dial tone.
o Event-driven modeling shows how a system responds to external and internal events.
o It is based on the assumption that a system has a finite number of states and that events
(stimuli) may cause a transition from one state to another.
69
State
▪States = nodes of the state machine
▪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
70
Transition
▪Change from one state to another
71
Example: Lecture Hall with Details
class LectureHall {
private boolean free;
72
4.3- Model-driven engineering
o Model-driven engineering (MDE) is an approach to software development where models
rather than programs are the principal outputs of the development process.
o The programs that execute on a hardware/software platform are then generated automatically
from the models.
o Proponents of MDE argue that this raises the level of abstraction in software engineering so
that engineers no longer have to be concerned with programming language details or the
specifics of execution platforms.
Pros
◦ Allows systems to be considered at higher levels of abstraction
◦ Generating code automatically means that it is cheaper to adapt systems to new platforms.
Cons
◦ Models for abstraction and not necessarily right for implementation.
◦ Savings from generating code may be outweighed by the costs of developing translators for new
platforms.