Sunteți pe pagina 1din 112

Chapter 5 – System Modeling

30/10/2014 Chapter 5 System Modeling 1


Topics covered

 Context models
 Interaction models
 Structural models
 Behavioral models
 Model-driven engineering

30/10/2014 Chapter 5 System Modeling 2


System modeling

 System modeling is the process of developing abstract


models of a system, with each model presenting a
different view or perspective of that system.
 System 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).
 System modelling helps the analyst to understand the
functionality of the system and models are used to
communicate with customers.

30/10/2014 Chapter 5 System Modeling 3


Existing and planned system models

 Models of the existing system are used during requirements


engineering. They help clarify what the existing system does
and can be used as a basis for discussing its strengths and
weaknesses. These then lead to requirements for the new
system.
 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.
 In a model-driven engineering process, it is possible to
generate a complete or partial system implementation from
the system model.
30/10/2014 Chapter 5 System Modeling 4
System perspectives

 An external perspective, where you model the context


or environment of the system.
 An interaction perspective, where you model the
interactions between a system and its environment, or
between the components of a system.
 A structural perspective, where you model the
organization of a system or the structure of the data that
is processed by the system.
 A behavioral perspective, where you model the
dynamic behavior of the system and how it responds to
events.
30/10/2014 Chapter 5 System Modeling 5
UML diagram types

 Activity diagrams, which show the activities involved in


a process or in data processing .
 Use case diagrams, which show the interactions
between a system and its environment.
 Sequence diagrams, which show interactions between
actors and the system and between system components.
 Class diagrams, which show the object classes in the
system and the associations between these classes.
 State diagrams, which show how the system reacts to
internal and external events.

30/10/2014 Chapter 5 System Modeling 6


Use of graphical models

 As a means of facilitating discussion about an existing or


proposed system
 Incomplete and incorrect models are OK as their role is to
support discussion.
 As a way of documenting an existing system
 Models should be an accurate representation of the system but
need not be complete.
 As a detailed system description that can be used to
generate a system implementation
 Models have to be both correct and complete.

30/10/2014 Chapter 5 System Modeling 7


Context models

30/10/2014 Chapter 5 System Modeling 8


Context models

 Context models are used to illustrate the operational


context of a system - they show what lies outside the
system boundaries.
 Social and organisational concerns may affect the
decision on where to position system boundaries.
 Architectural models show the system and its
relationship with other systems.

30/10/2014 Chapter 5 System Modeling 9


System boundaries

 System boundaries are established to define what is


inside and what is outside the system.
 They show other systems that are used or depend on the system
being developed.
 The position of the system boundary has a profound
effect on the system requirements.
 Defining a system boundary is a political judgment
 There may be pressures to develop system boundaries that
increase / decrease the influence or workload of different parts of
an organization.

30/10/2014 Chapter 5 System Modeling 10


The context of the Mentcare system

30/10/2014 Chapter 5 System Modeling 11


Process perspective

 Context models simply show the other systems in the


environment, not how the system being developed is
used in that environment.
 Process models reveal how the system being developed
is used in broader business processes.
 UML activity diagrams may be used to define business
process models.

30/10/2014 Chapter 5 System Modeling 12


Process model of involuntary detention

30/10/2014 Chapter 5 System Modeling 13


Interaction models

30/10/2014 Chapter 5 System Modeling 14


Interaction models

 Modeling user interaction is important as it helps to


identify user requirements.
 Modeling system-to-system interaction highlights the
communication problems that may arise.
 Modeling component interaction helps us understand if a
proposed system structure is likely to deliver the required
system performance and dependability.
 Use case diagrams and sequence diagrams may be
used for interaction modeling.

30/10/2014 Chapter 5 System Modeling 15


Use case modeling

 Use cases were developed originally to support


requirements elicitation and now incorporated into the
UML.
 Each use case represents a discrete task that involves
external interaction with a system.
 Actors in a use case may be people or other systems.
 Represented diagrammatically to provide an overview of
the use case and in a more detailed textual form.

30/10/2014 Chapter 5 System Modeling 16


Transfer-data use case

 A use case in the Mentcare system

30/10/2014 Chapter 5 System Modeling 17


UML Notation for Use Case Modeling
UML Notation for Use Case Modeling
UML Notation for Use Case Modeling
Tabular description of the ‘Transfer data’ use-
case

MHC-PMS: Transfer data


Actors Medical receptionist, patient records system (PRS)
Description A receptionist may transfer data from the Mentcase
system to a general patient record database that is
maintained by a health authority. The information
transferred may either be updated personal information
(address, phone number, etc.) or a summary of the
patient’s diagnosis and treatment.
Data Patient’s personal information, treatment summary
Stimulus User command issued by medical receptionist
Response Confirmation that PRS has been updated
Comments The receptionist must have appropriate security
permissions to access the patient information and the
PRS.

30/10/2014 Chapter 5 System Modeling 21


Use cases in the Mentcare system involving the
role ‘Medical Receptionist’

30/10/2014 Chapter 5 System Modeling 22


Actors

 Could be human beings or other system.


 2 types of actor classification:
 Primary Actors: The stakeholder who or which initiates an
interaction with the system to achieve a goal.(left side)
 Secondary Actors: Provides a service to the system. (right
side)
 Actor Designing Consideration:
 Who / what will be interested in the system?
 Who / what will want to change the data in the system?
 Who / what will want to interface with the system?
 Who / what will want information from the system?
Actor/ Use Case Generalization

 Used when you find 2 or more use cases that have


commonalities in behavior, structure and purpose.

 A parent use case may be specialized into 1 or more


child use cases that represent more specific form of the
parent.

 For example, suppose the ATM system can be used


to pay bills. Pay bills has two child use cases: Pay
Credit Card Bill and Pay Utility Bill
Actor/ Use Case Generalization
Include Relationship

 Used when 2 or more use cases share some common


portion in a flow of events.

 The common portion is grouped and extracted to


form an inclusion use case to be shared among the
use cases related.

 For example, in the ATM system example, such as


Withdraw Money, Deposit Money or Check Balance, all
share the inclusion use case Login Account
Include Relationship
Include Relationship
Extend Relationship

 Extended use case is meaningful on its own, it is


independent of the extending use case. Extending use
case typically defines optional behavior.
 The extension use case adds extra behavior to the base
use case.
 For example, Withdraw Money has an optional behavior
which handles withdrawal of an excess amount
Extend Relationship
Task 1

 Establish Generalize Relationship

 An order management system accepts ordering of product


by phone or internet. Write the generalization for this, where
that base use case will be used by the order registry clerk.
Task 1 Solution
Assignment No2

 Quesion#1:
 Establish <<Include>> and <<Extend>> Relationships

 Consider an online flight booking system. A user will search for


an available flight time and book the flight if desired. The user
will be able to check if there is any seat available, either when
searching or booking a flight.

 As part of an online flight booking system, the customer may


have the option to upgrade their seat (e.g economy to business
class) when making flight booking.
Assignment No2
Question#2:
Case Study
 Create the UML Use Case Diagram for a system to buy DVDs
online. Customers, Delivery Agent, and Administrators of the System will
use the system. They can perform the following actions in the system:
 Customer:
 Add a DVD to shopping cart (requires the user to log in)
 Remove a DVD from shopping cart (requires the user to log in)
 Check out shopping cart (requires the user to log in)
 Review contents of shopping cart (requires the user to log in)
 Search DVDs by Title and Category (Some examples of categories are: Series, Movies,
Music)

 Delivery Agent:
 Check online orders
 Change the status of the order to delivered

 Administrator:
 Add DVD
 Update inventory of DVDs

 Note: Use the “include” and “extend” relationships as needed.


Sequence diagrams

 Sequence diagrams are part of the UML and are used to


model the interactions between the actors and the
objects within a system.
 A sequence diagram shows the sequence of interactions
that take place during a particular use case or use case
instance.
 The objects and actors involved are listed along the top
of the diagram, with a dotted line drawn vertically from
these.
 Interactions between objects are indicated by annotated
arrows.
30/10/2014 Chapter 5 System Modeling 35
Sequence Diagram

 The sequence diagram consists of objects represented


in the usual way (as named rectangles with the name
underlined), messages represented as solid-line arrows,
and time represented as a vertical progression
Objects

 The objects are laid out near the top of the diagram from
left to right..

 Extending downward from each object is a dashed line


called the object's lifeline.

 Along the lifeline is a narrow rectangle called an


activation. The activation represents an execution of
an operation the object carries out. The length of
the rectangle signifies the activation's duration.
Representing an Object
Time

The diagram represents time in the vertical


direction: Time starts at the top and progresses
toward the bottom.
Thus, the sequence diagram is two-dimensional.
The left-to-right dimension is the layout of the
objects, and the top-to-bottom dimension
shows the passage of time.
Messages

A message that goes from one object to another


goes from one object's lifeline to the other
object's lifeline.
An object can also send a message to itself—
that is, from its lifeline back to its own lifeline.

Type of Messages in Sequence Diagrams


 Synchronous
 Asynchronous
 Recursive
Synchronous Message

One type of message is a call. This is a


request from the object sending the message
to the object receiving the message. The
request is for the receiver to carry out one of
its (the receiver's) operations. Because the
sender waits for the receiver (that is, "synchs
up" with the receiver), this message is also
referred to as synchronous.
Asynchronous Message

With this one, the sender transfers control to the


receiver and doesn't wait for the operation to
complete
Recursive Message
Symbols in a Sequence Diagram
Creation Message

Element Creation: when an element is created during an


interaction, the communication that creates the element is shown
with its arrowhead to the element.
Destruction Message

Element Destruction: When an element is destroyed during an


interaction, the communication that destroys the element is shown
with its arrowhead to the elements lifeline where the destruction is
marked with a large × symbol.
Message Type Notations
Message Type Notations
Example
Another Example

Model of a Soda Machine


A sequence diagram that models the
best case scenario of Buy- Soda use
case
A sequence diagram that models the
sold-out scenario of Buy- Soda use case
A sequence diagram that models the
incorrect-change scenario of Buy- Soda use case
A generic sequence diagram of
Buy- Soda use case
Combined Fragment in SD

• Combined fragment is about fragmenting sequence into different parts


and combining those to show larger sequence.

• UML 2 introduces this concept.

• Through the use of combined fragments the user will be able to describe
a number of traces in a compact and concise manner.
Sequence Fragments
Common Operators for
Interaction Frames
Alternatives
Contains a list of fragments that contain alternative sequences
of messages. Only one sequence occurs on any occasion.
Option
the fragment executes only if the supplied condition is true.
Equivalent to an alt only with one trace.
Loop

The fragment repeats some number of times. You can


indicate in the guard the condition under which it should
repeat.
Parallel
The interaction operator par defines potentially parallel
execution of behaviors of the operands of the combined
fragment.
Sequence diagram for View patient information

30/10/2014 Chapter 5 System Modeling 63


Sequence
diagram for
Transfer Data
30/10/2014 Chapter 5 System Modeling 64
Structural models

30/10/2014 Chapter 5 System Modeling 65


Structural models

 Structural models of software display the organization of


a system in terms of the components that make up that
system and their relationships.
 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.
 You create structural models of a system when you are
discussing and designing the system architecture.

30/10/2014 Chapter 5 System Modeling 66


Class diagrams

 Class diagrams are used when developing an object-


oriented system model to show the classes in a system
and the associations between these classes.
 An object class can be thought of as a general definition
of one kind of system object.
 An association is a link between classes that indicates
that there is some relationship between these classes.
 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.
30/10/2014 Chapter 5 System Modeling 67
UML classes and association

30/10/2014 Chapter 5 System Modeling 68


Classes and associations in the MHC-PMS

30/10/2014 Chapter 5 System Modeling 69


The Consultation class

30/10/2014 Chapter 5 System Modeling 70


Generalization

 Generalization is an everyday technique that we use to


manage complexity.
 Rather than learn the detailed characteristics of every
entity that we experience, we place these entities in
more general classes (animals, cars, houses, etc.) and
learn the characteristics of these classes.
 This allows us to infer that different members of these
classes have some common characteristics e.g.
squirrels and rats are rodents.

30/10/2014 Chapter 5 System Modeling 71


Generalization

 In modeling systems, it is often useful to examine the classes in


a system to see if there is scope for generalization. If changes
are proposed, then you do not have to look at all classes in the
system to see if they are affected by the change.
 In object-oriented languages, such as Java, generalization is
implemented using the class inheritance mechanisms built into
the language.
 In a generalization, the attributes and operations associated with
higher-level classes are also associated with the lower-level
classes.
 The lower-level classes are subclasses inherit the attributes and
operations from their superclasses. These lower-level classes
then add more specific attributes and operations.
30/10/2014 Chapter 5 System Modeling 72
A generalization hierarchy

30/10/2014 Chapter 5 System Modeling 73


A generalization hierarchy with added detail

30/10/2014 Chapter 5 System Modeling 74


Object class aggregation models

 An aggregation model shows how classes that are


collections are composed of other classes.
 Aggregation models are similar to the part-of relationship
in semantic data models.

30/10/2014 Chapter 5 System Modeling 75


The aggregation association

30/10/2014 Chapter 5 System Modeling 76


UML Class Notation: Composition

 Composition
• Strong form of Aggregation.
• components have only one owner.
• Lifetime control; components cannot exist
without the aggregate i.e components cannot
exist independent of their owner.
• Indicated by a solid diamond on the side of
the collection.
UML Class Notation
Association: Multiplicity and Roles

student
1 *

University Person

0..1 *
employer teacher
Multiplicity
Symbol Meaning Role Role
1 One and only one “A given university groups many
people; some act as students, others
0..1 Zero or one as teachers. A given student
M..N From M to N (natural language) belongs to a single university; a
given teacher may or may not be
* From zero to any positive integer working for the university at a
0..* From zero to any positive integer particular time.”

1..* From one to any positive integer


UML Class Notation
Practice

 Each employee works for one company (which can have 0


employees)

 Each Company has exactly one BoardOfDirectors (and


viceversa)

 Each Office is allocated to zero or more Employees (an


Employee can have no office or at most one)

 A Person is boardMember of 0 or more BoardOfDirectors


(each BoardOfDirectors has from 3 to 8 Persons)
Practice

 Room has 1 Thermostat. Each Thermostat is associated


with 0 or more Heaters. A Heater has exactly one
Thermostat. Electric Heater is a specialized Heater.

 A book is composed of a number of parts, which in turn


are composed of a number of chapters. Chapters are
composed of sections.
Notation of Class Diagram: Generalization

Supertype Example: Customer

Regular Loyalty
Customer Customer

Subtype1 Subtype2
or: Customer

Generalization expresses a
relationship among related
classes. It is a class that Regular Loyalty
includes its subclasses. Customer Customer
Notation of Class Diagram:
Generalization

 Specialization is the reverse process of Generalization


means creating new sub classes from an existing class.
Assignmant3 Part1
Draw Class diagram

In a university, there are different classrooms, offices and


departments. A department has a name and it contains
many offices. A person working at the university has a
unique ID and can be a professor or an employee. A
professor can be a full, associate or assistant professor
and he/she is enrolled in one department. Offices and
classrooms have a number ID, and a classroom has a
number of seats. Every employee works in an office. Draw
class diagram.
.
Assignmant3 part 2
Draw Class diagram

A laboratory has several chemists who work on one or more projects.


Chemists (empid, Name, Phone_no) also may use certain kinds of
equipments (Serial_no, cost) on each project (projected, start_date). The
organization wishes to record assign-date i.e., the date when the given
equipment item was assigned to a particular Chemist working on a specific
project, as well as total number of hours the chemist has used the
equipment for the project. The chemist must be assigned to at least one
project and one equipment item. A particular equipment item need not be
assigned either to a chemist or a project, and a given project need not be
assigned either a chemist or equipment item. Draw the class diagram.
Behavioral models

30/10/2014 Chapter 5 System Modeling 87


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.

30/10/2014 Chapter 5 System Modeling 88


Data-driven modeling

 Many business systems are data-processing systems


that are primarily driven by data. They are controlled by
the data input to the system, with relatively little external
event processing.
 Data-driven models show the sequence of actions
involved in processing input data and generating an
associated output.
 They are particularly useful during the analysis of
requirements as they can be used to show end-to-end
processing in a system.

30/10/2014 Chapter 5 System Modeling 89


An activity model of the insulin pump’s
operation

30/10/2014 Chapter 5 System Modeling 90


Order processing

30/10/2014 Chapter 5 System Modeling 91


Event-driven modeling

 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.
 Event-driven modeling 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 (stimuli) may cause a
transition from one state to another.

30/10/2014 Chapter 5 System Modeling 92


State machine models

 These model the behaviour of the system in response to


external and internal events.
 They show the system’s responses to stimuli so are
often used for modelling real-time systems.
 State machine models show system states as nodes and
events as arcs between these nodes. When an event
occurs, the system moves from one state to another.
 Statecharts are an integral part of the UML and are used
to represent state machine models.

30/10/2014 Chapter 5 System Modeling 93


Activity Diagram

 The activity diagram is much like the flowcharts of old. It


shows steps (activities) as well as decision points and
branches. It is useful for showing what happens in a
business process or an operation.
The Basics: What is an Activity Diagram

Each activity is represented by a rounded


rectangle—narrower and more oval-shaped.
The processing within an activity goes to
completion and then an automatic transmission
to the next activity occurs.
An arrow represents the transition from one
activity to the next.
The activity diagram has a starting point
represented by a filled-in circle and an endpoint
represented by a bull's-eye.
Transitioning from one activity to another
Basic symbols
Basic symbols
Basic symbols

Time Event
This refers to an event that stops the flow for a time; an hourglass
depicts it.

Sent and Received Signals


Signals represent how activities can be modified from outside the
system. They usually appear in pairs of sent and received signals,
because the state can't change until a response is received, much
like synchronous messages in a sequence diagram. For example, an
authorization of payment is needed before an order can be
completed.
Decisions

 A sequence of activities almost always comes to a point where a


decision has to take place.
 One set of conditions leads to one path, another set of conditions to
another path, and the two paths are mutually exclusive.
 You can represent a decision point in either of two ways.
 One way is to show the possible paths coming directly out of an
activity.
 The other is to have the activity transition to a small diamond—
reminiscent of the decision symbol in a flowchart—and have the
possible paths flow out of the diamond.
The two ways of showing a decision
Concurrent Paths

As you model activities, you'll occasionally have


to separate a transition into two separate paths
that run at the same time (that is, concurrently)
and then come together.
To represent the split, you use a solid bold line
perpendicular to the transition and show the
paths coming out of the line.
Representing a transition split into two paths
that run
concurrently and then come together
Object Nodes

 Object change state during or as result of some process.


 Activity diagram can show status of object at various
point in given process.
Signals

 During a sequence of activities, it’s possible to send a


signal. When received, the signal causes an activity to
take place. The symbol for sending a signal is a convex
polygon, and the signal for receiving a signal is concave
polygon.
 In UML term, convex polygon symbolizes an output
event; the concave polygon symbolizes an input event.
Sending and receiving a signal
Sub activity diagram

 Sub activity diagram allows to decompose the


functionality in an activity diagram.
 Lets you show an action in more detail.
Example

A Process: Creating a Document


Think of the activities that go into using an office software suite to create a document. One

possible sequence of activities is

1. Open the word processing package.


2. Create a file.
3. 3. Save the file under a unique name within its directory.
4. Type the document.
5. If graphics are necessary, open the graphics package, create the graphics, and paste
the graphics into the document.
6. If a spreadsheet is necessary, open the spreadsheet package, create the
spreadsheet, and paste the spreadsheet into the document.
7. Save the file.
8. Print a hard copy of the document.
9. Exit the office suite
An activity diagram for the
process of creating a
document
Task

 An example of business flow activity of order processing,


Requested order is input parameter of the activity. After
order is accepted and all required information is filled in,
payment is accepted and order is shipped.
Key points

 Behavioral models are used to describe the dynamic behavior


of an executing system. This behavior can be modeled from
the perspective of the data processed by the system, or by
the events that stimulate responses from a system.
 Activity diagrams may be used to model the processing of
data, where each activity represents one process step.
 State diagrams are used to model a system’s behavior in
response to internal or external events.
 Model-driven engineering is an approach to software
development in which a system is represented as a set of
models that can be automatically transformed to executable
code.
30/10/2014 Chapter 5 System Modeling 112

S-ar putea să vă placă și