Software Engineering Lec7
Software Engineering Lec7
System Modelling
Topics covered
l Introduction
l Context Model
l Activity Diagram
l Structural Model
l Class Diagram
l Interaction Model
l Use case Diagram
l Sequence Diagram
l Behavioural Model
l State Machine Diagram
l Conclusion
Introduction
l System modeling is the process of developing abstract models of a system
l Each model presents a different view or perspective of that system
l Each model is represented based on graphical notations using UML(Unified
Model Language)
l Model is used in Requirement Engineering Phase –
• to help derive the requirements for a system
l Model is used in Design Phase –
• to describe the system to engineers implementing the system
l Model is used after Implementation Phase-
• To document the system’s structure and operation
l We may develop models of both
• The existing system –
• What the existing system does
• To discuss the strengths and weaknesses
• These lead to requirements for the new system
• The system to be developed
• To explain the proposed system to other system stakeholders
• Engineers use these models to discuss design proposals and to document the system for
implementation
Introduction
l Different Model is shown from different perspective
• External Perspective :
• The context or environment of the system is modeled
• Interaction Perspective :
• The interactions between a system and its environment or the components of
the system is modeled
• Structural Perspective :
• The organization of the system or
• The structure of the data that is processed by the system
• Behavioral Perspective :
• The dynamic behavior of the system
• How it responds to events
Introduction
l Diagrams to document the system model
• Activity Diagram :
• It shows the activities involved in a process or in data processing
• Use Case Diagram :
• It shows the interactions between a system and its environment
• Sequence Diagram :
• It shows the interactions between the actors and the system and between
system components – it emphasizes on when interactions occur
• Collaboration Diagram :
• It shows the interactions between the actors and the system and between
system components – it emphasize on what interactions occur
• Class Diagram :
• It shows the object classes in the system and the associations between these
classes
• State Diagram :
• It shows how the system reacts to internal and external events
Introduction
l Three ways in which graphical models are
commonly used
• As a means of facilitating discussion about an existing or
proposed system
• As a way documenting an existing system
• As a detailed system description that can be used to
generate a system implementation
Context Models
l At early stage in specification, we should decide the system
boundaries
l By discussing with the stakeholders, we should decide on
• What functionality should be included in the system
• What is provided by the system’s environment
• What business process should be implemented
• What processes should be manual or supported by different
system
• Look at possible overlaps in functionality with existing system
• Where new functionality should be implemented
l Reasons to decide on system boundaries
• To limit the system costs and the time needed for understanding
the system requirements and design
Activity Diagram
l Activity Diagrams are intended to show
• The activities that make up system process
• The flow of control from one process or action to another
• The activity diagram cannot be exactly matched with the code
l Purposes of Activity Diagram
• Draw the activity flow of a system.
• Describe the sequence from one action to another.
• Describe the parallel, branched and concurrent flow of the system
How to draw Activity Diagram?
l Understand about the elements used in activity diagram
• Activities and actions
• Association
• Conditions
• Constraints
l Make a mental layout of the entire flow of actions within activity
Understand the elements of Make a mental layout Transform the mental layout
activity diagram of entire flow into activity diagram
Notation of Activity Diagram
Start of a
process
Fork Node
End of a
process
Activities
and Action Join Node
Flow of
work
[Normal Order]
https://www.visual-paradigm.com/guide/uml-unified-modeling-language/uml-class-diagram-tutorial/
UML Notation of Class Diagram
l UML diagrams can include a label known as
a stereotype, above the class name in a class diagram.
l This would be placed inside << >> marks, like this:
• <<entity>>
• <<boundary>>
• <<control>>
UML Notation of Class Diagram
l Class Visibility
• + denotes public attributes or operations
• - denotes private attributes or operations
• # denotes protected attributes or operations
https://www.visual-paradigm.com/guide/uml-unified-modeling-language/uml-class-diagram-tutorial/
UML Notation of Class Diagram
l Parameter Directionality
• Each parameter in an operation (method) may be
denoted as in, out or inout which specifies its direction
with respect to the caller
https://www.visual-paradigm.com/guide/uml-unified-modeling-language/uml-class-diagram-tutorial/
UML Notation of Class Diagram
l Perspectives of Class Diagram
• Conceptual: represents the concepts in the domain
• Specification: focus is on the interfaces of Abstract Data
Type (ADTs) in the software
• Implementation: describes how classes will implement
their interfaces
https://www.visual-paradigm.com/guide/uml-unified-modeling-language/uml-class-diagram-tutorial/
UML Notation of Class Diagram
l Relationships between classes
• A class may be involved in one or more relationships with
other classes
https://www.visual-paradigm.com/guide/uml-unified-modeling-language/uml-class-diagram-tutorial/
UML Notation of Class Diagram
l Association
• A naturally occurring relationship between classes ( UML term)
• Associations are relationships between classes in a UML Class
Diagram
• They are represented by a solid line between classes in UML.
• Associations are typically named using a verb or verb phrase
which reflects the real world problem domain
Accounting
Order # 123 “is placed by” “Works in ”
Dept.
“Mr. Smith”
“Contains” “Contains”
Jeans Shirt
https://www.visual-paradigm.com/guide/uml-unified-modeling-language/uml-class-diagram-tutorial/
UML Notation of Class Diagram
l Simple Association (Bidirectional Association)
l A structural link between two peer classes.
l One class uses another class
l There is an association between Class1 and Class2
l There is an association that connects the <<control>>
class Class1 and <<boundary>> class Class2
l The relationship is displayed as a solid line connecting the
two classes.
LogInControl LogInPage
https://www.visual-paradigm.com/guide/uml-unified-modeling-language/uml-class-diagram-tutorial/
UML Notation of Class Diagram
Directed Association (Unidirectional Association)
l refers to a directional relationship represented by a line
with an arrowhead
l The arrowhead depicts a container-contained directional
flow
Notification Member
Sentto
https://creately.com/blog/diagrams/class-diagram-relationships/
UML Notation of Class Diagram
Dependency :
l A special type of association.
l Exists between two classes if changes to the
definition of one may cause changes to the other
(but not the other way around).
l Class1 depends on Class2
l The relationship is displayed as a dashed line with
an open arrow.
l The Person class might have a hasRead method
with a Book parameter that returns true if the
person has read the book (perhaps by checking
CourseSchedule Course
some database).
+add(): void
+remove() : void
https://www.visual-paradigm.com/guide/uml-unified-modeling-language/uml-class-diagram-tutorial/
UML Notation of Class Diagram
Reflexive Association :
l This occurs when a class may have multiple
functions or responsibilities.
l For example, a staff member working in an airport
may be a pilot, aviation engineer, a ticket
dispatcher, a guard, or a maintenance crew
member. If the maintenance crew member is
managed by the aviation engineer there could be a
managed by relationship in two instances of the
same class.
https://creately.com/blog/diagrams/class-diagram-relationships/
UML Notation of Class Diagram
l Multiplicity is term for the number of associations
between classes
• 1 to 1
• 1 to many
• Many to 1
• Many to many
• It is placed on the opposite end of the
association line
https://www.visual-paradigm.com/guide/uml-unified-modeling-language/uml-class-diagram-tutorial/
UML Notation of Class Diagram
Customer Account Branch
ID ID ID
Name 1..* AccType Name
Phone 1 Balance 0..* 1 Phone
add() add() add()
delete() delete() delete()
Update() Update() Update()
1
1..*
Transaction
ID
Type
Amount
add()
delete()
Update()
UML Notation of Class Diagram
l Inheritance or Generalization
• A generalization is a taxonomic relationship between a
more general classifier and a more specific classifier
• Each instance of the specific classifier is also an indirect
instance of the general classifier
• the specific classifier inherits the features of the more
general classifier.
• Represents an "is-a" relationship.
• An abstract class name is shown in italics.
• SubClass1 and SubClass2 are specializations of
SuperClass.
• The relationship is displayed as a solid line with a hollow
arrowhead that points from the child element to the parent
element.
https://www.visual-paradigm.com/guide/uml-unified-modeling-language/uml-class-diagram-tutorial/
UML Notation of Class Diagram
l Aggregation (Hollow Diamond)
• It represents a "part of" relationship
• Object of one class has object of another
• Second is a part of first
• Class2 is part of Class1
• Many instances (denoted by the *) of Class2 can be
associated with Class1
• Objects of Class1 and Class2 have separate lifetimes
• The relationship is displayed as a solid line with a unfilled
diamond at the association end, which is connected to the
class that represents the aggregate
Head Light
Car
Engine
https://www.visual-paradigm.com/guide/uml-unified-modeling-language/uml-class-diagram-tutorial/
UML Notation of Class Diagram
l Composition (Filled Diamond)
• A special type of aggregation where parts are destroyed
when the whole is destroyed. Scroll Bar
• That is, the contained class will be obliterated when the
container
Window class is destroyed
• Title Bar
Objects of Class2 live and die with Class1.
• Class2 cannot stand by itself.
• Menu
The relationship is displayed as a solid line Bar
with a filled
diamond at the association end, which is connected to the
class that represents the whole or composite.
https://www.visual-paradigm.com/guide/uml-unified-modeling-language/uml-class-diagram-tutorial/
UML Notation of Class Diagram
l Realization
• Realization is a relationship between the blueprint class
and the object containing its respective implementation
level details.
• This object is said to realize the blueprint class.
• In other words, you can understand this as the
relationship between the interface and the implementing
class.
• For example, the Owner interface might specify methods
for acquiring property and disposing of property. The
Person and Corporation classes need to implement these
methods, possibly in very different ways.
https://www.visual-paradigm.com/guide/uml-unified-modeling-language/uml-class-diagram-tutorial/
Case Study
Use Case Scenario:
1. Customer verifies items in shopping cart.
2. Customer provides payment and address to process sales
3. System validates payment and responds by confirming order and
provides order number that customer can use to check an order status
4. System will send customer a copy of order details by email
Case Study
Use Case Scenario:
1. Customer verifies items in shopping cart.
2. Customer provides payment and address to process sales
3. System validates payment and responds by confirming order and
provides order number that customer can use to check an order status
4. System will send customer a copy of order details by email
Noun List:
1. Customer 7. System
2. items 8. order
3. shopping cart 9. order number
4. payment 10. order status
5. Address 11. order details
6. sales 12. email
Case Study
Use Case Scenario:
1. Customer verifies items in shopping cart.
2. Customer provides payment and address to process sales
3. System validates payment and responds by confirming order and
provides order number that customer can use to check an order status
4. System will send customer a copy of order details by email
Noun List:
1. Customer 7. System
2. Items 8. order
3. Shopping cart 9. order number
4. Payment 10. order status
5. Address 11. order details
6. sales 12. Email
Case Study
l Conceptual Class Diagram
Uses Contains
Customer Shopping Cart Items
1 *
Places
Address
Case Study
Use Case Scenario:
1. Customer verifies items in shopping cart.
2. Customer provides payment and address to process sales
3. System validates payment and responds by confirming order and
provides order number that customer can use to check an order status
4. System will send customer a copy of order details by email
Verb List:
1. Verify Item 5. Confirm Order
2. Provide Payment and address 6. Provide Order Number
3. Process Sales 7. Check an order status
4. Validate Payment 8. Send order details email
1. Verify Item
2. Provide Payment and
Case Study 3.
address
Process Sale
4. Validate Payment
5. Confirm Order
6. Provide Order Number
7. Check an order status
8. Send order details email
Uses Contains
Customer Shopping Cart Item
1 *
Places
Display Totals
https://www.visual-paradigm.com/guide/uml-unified-modeling-language/uml-class-diagram-tutorial/
Class Diagram Example: GUI
https://www.visual-paradigm.com/guide/uml-unified-modeling-language/uml-class-diagram-tutorial/
Interaction Model
l Types of interaction
• User interaction: it involves user inputs and outputs
• Interaction between the system being developed and
other systems
• Interaction between the components of the system
l Modeling User Interaction
• Helps to identify user requirements
l Modeling System to System interaction
• Highlights the communication problems that may arise
l Modeling component interaction
• Helps us understand if a proposed system structure is
likely to deliver the required system performance and
dependability
Interaction Model
l Approaches of interaction modeling
• Use Case Modeling
• To model interactions between a system and external
actors (users or other systems)
• Sequence Diagram
• To model interactions between system components
• It may include external agents
Use Case Modeling
l It is developed by Jcobson et al. 1993
l Use Case :
• A simple scenario that describes what a user expects
from system
l Each Use Case represents a discrete task that
involves external interaction with a system
Transfer
Data
:System
Life line
addItem (itemId, quantity)
description, price
Activation
Box
Notation of Sequence Diagram
l Loop frame is represented using a rectangle, where test condition for
repetition is written in left corner
Actor object
Test Condition
for Repetition :System
Actor object
:System
Opt
[item selected ] addItem (itemId, quantity)
Item detailed
Notation of Sequence Diagram
l Alt Frame (If-Else)
• Alt is written in the left corner of the rectangle
• Brackets [] is used for true/false condition
• If it evaluates to true, then the message is sent
• Otherwise the message of “else” is sent
:System
Alt
[Taxable item] addTax(location code)
Sales Tax
[Else] addTaxExempt(code)
Tax exempted detail
Steps of Sequence Diagram
1. Identify input message
-See use case flow of activity or activity diagram
2. Describe the message from the external actor to the system
using the message notation
-Name it verb-noun : what the system asked to do
-Consider parameters the system will need
3. Identify any special conditions on input
- Iteration/loop frame
-Opt or alt frame
4. Identify and add output return values
- An explicit return on separate dashed line
View Information
Medical Receptionist
P:Patientinfo D:MHCPMS-DB AS: Authorization
ViewInfo(PID)
Report (Info,PID,UID)
Authorize(Info,UID)
Authorization
Alt
[Authorization
Fail]
Error No Access
Transfer Data
Medical Receptionist PRS
P:Patientinfo D:MHCPMS-DB AS: Authorization
Login()
OK
Alt
[SendInfo]
UpdateInfo() Update PRS (UID) Authorize(TF,UID)
Authorization Update (PID)
Update Ok
Message (Ok)
[SendSummery]
UpdateSummery()
Summarize (UID) Authorize(TF,UID)
Authorization
:Summery
Update(PID)
Message (Ok) Update Ok
Logout()
Behavioral Model
l Behavioral models are models of the dynamic
behavior of the system as it is executing
l They show what happens or what is supposed to
happen when a system responds to a stimulus from
its environment
l Two types
• Data-Driven Modeling
• It shows the sequence of actions involved in processing input data
and generating an associated output
• DFD
• Event-Driven Modeling
• It shows how a system responds to external and internal events
• It is based on the assumption that a system has a finite number of
states and that events may cause a transition from one state to
other
• State-Machine Diagram
State Machine Diagram
l The UML diagram
• It describe the behavior of one object over several use
cases in the system
• It shows the life of an object in states and transitions
• It is described for a class
• Each object has it’s own state machine
l States
• A condition during an objects life when it
• Satisfies some criterion
• Performs some action and
• Waits for an event
l Action
• It is an executable atomic computation
• It includes operation calls, the creation or destruction of
another object or sending of a signal to an object
State Machine Diagram
l A state is represented by a rounded rectangle that contains the state
name
l Event
• It is described as Event-Name(comma- separated- parameter list )
• Events appear in the internal transition of a state or on a transition
between states
State Name
Action performed on entry to State
At work
Action performed while in State
Entry/Unlock Door
Do/Prepare Materials Action performed while arrival of named event
Telephone ring / answer
Include/Lecture State Name of sub-state machine
Exit/ Lock Door
Action performed on leaving State
State Machine Diagram
l Start / Pseudo state State
• The starting point of a state machine diagram
• It is represented by a solid circle
l Final State
• A final state is reached when the object's lifetime is over
• It is represented by a solid circle surrounded by an open circle
l Original / source state
• The original state of an object before transition
l Destination state
• The state to which the object moves after the transition
l Guard Condition
• A true false test to see whether a transition can fire
State Machine Diagram
l Action Expression
• A description of activities performed as a part of transition
l Transition
• The movement of object from one state to other state
• A transition string is described as
• Event-signature [guard condition] action expression
l States are connected together by transitions that
point from a source state to a destination state
• The behavior that causes the state change, such as an
event, conditions, or time, if there is any, is described
near the arrow
• A transition with no events, conditions, or time limits, is
performed automatically upon completion of the state's
activities
State Machine Diagram
go to home
At work At Home
go to work
die die
State Machine Diagram
Invoice Invoice
created Unpaid paying Paid destroyed
State Machine Diagram
offButtonPushed
State Machine Diagram
l Steps for developing State Machine Diagram
• Review the class diagram and select classes that might require machine
diagrams
• For each class, make a list of status conditions (states) you can identify
• Identify transitions that cause an object to leave the identified state
• Sequence these states in the correct order
• Review paths and look for independent, concurrent paths
• Look for additional transitions and test for both directions
• Expand each transition with appropriate message event, guard condition
and action expression
• Review and test the state machine diagram for the class
• Make sure state are the really state for the object in the class
• Follow the lifecycle of an object coming into existence and being deleted
• Be sure diagram covers all exception condition
• Look again for concurrent paths and composite states
State Machine Diagram
BookCopy
Accession_No
Title OnSelf:=‘Y’ on the self
OnSelf : Boolean
OnSelf:=‘N’ on loan
Type
object is myBkCpy