Lecture2010 7
Lecture2010 7
LECTURE 7:
The Object-Oriented Approach to
Requirements
1
Lecture Outline
Unified Modeling Language (UML)
Object-Oriented Requirements (OOR)
System Activities
Use Case Diagram
Activity Diagram
System Sequence Diagram
State Machine Diagram
Integrating Object-Oriented Models
2
The Domain Model Class Diagram
4
UML Class Symbol
5
Class Diagram
Classes, associations among classes and
attributes of classes are modeled using a class
diagram
The class diagram shows some of the behaviors
of objects of the class, called method
Methods of a class are the behaviors all objects
in the class are capable to do.
A behavior is an action that the object processes
itself, when asked to do so by sending it a
message from another object
Since each object contains values for attributes
and methods for operating on those attributes
(plus other behaviors), an object is said to be
encapsulated (i.e., a self-contained and
protected unit) 6
Simple Domain Model Class
Diagram
7
Simple Domain Model Class
Diagram (continued)
No methods shown in domain model
Domain classes are not software
classes
Very similar to ERD
UML and domain model can be used in
place of ERD in traditional approach
8
Multiplicity of Associations
9
University Course Enrollment
Domain Model Class Diagram
10
Refined Model with Association
Class and Grade Attribute
11
More Complex Class Concepts
Generalization/specialization
hierarchies
Inheritance
Aggregation
12
Generalization/Specialization
Generalization means grouping similar types of
things (e.g., motor vehicles group cars, trucks and
tanks. They share certain general features (e.g.,
wheels, engine, etc.), so motor vehicle is a more
general class)
Specializations are judgments that categorize
different types of things (e.g., sports car is a
special type of car)
A generalization/specialization hierarchy is
used to structure (or rank) things from the more
general down to the more special
Each class has a more general class above it – a
superclass
A class may have a more specialized class below –
a subclass
13
A Generalization/Specialization
Class Hierarchy for Motor Vehicles
14
A Generalization/Specialization
Class Hierarchy for RMO Orders
15
Inheritance
Inheritance is a concept that allows subclasses
to share characteristics of their superclasses
• E.g. a sports car has everything a car has (e.g., 4
wheels and an engine, which it inherits from the
class car which is above it)
• The sports car then specializes
–E.g., has a sports option, racing wheels, etc.
• In the object-oriented approach, inheritance is a
key concept that is possible because of
generalization/specialization hierarchies (these
hierarchies are often called inheritance
hierarchies)
16
Whole-Part Hierarchies
18
Class Diagram Example: Bank
Account
• Bank account system includes a generalization/specialization
hierarchy:
– Account is the superclass
– SavingsAccount and CheckingAccount are subclasses of
Account
– A triangle on the line connecting classes indicates
inheritance (the subclasses inherit attributes and behaviors from
the superclass Account like having an account number)
• But Savings and Checking accounts are also specialized
• A SavingsAccount “knows” how to calculate interest but a
checking account doesn’t (so they have different methods and
attributes, although they share things they inherit from class
Account)
19
Class Diagram Example: Bank
Account
• The Customer class and the Account class are associated
– Each customer can have zero or more accounts (the
diagram shows the minimum and maximum cardinality on the
line connecting the classes, and the asterisk means “many”
– Each account is owned by one and only one customer
• The SavingsAccount and CheckingAccount classes inherit
the association with the Customer class
• The Account class is an abstract class (i.e., the class that
cannot be instantiated, existing only to allow subclasses to
inherit its attributes, methods and associations) – shown in italics
• SavingsAccount, CheckingAccount and Customer are
examples of class are concrete classes that can be
instantiated (i.e., objects can be created)
20
A bank account system class
diagram
21
Association Class
23
The RMO Domain Class Diagram
• A generalization/specialization hierarchy
is included to show three types of orders –
web order, telephone order and mail
order, which share the attributer listed for
Order class, but each special type of order
has some additional attributes
• This diagrams shows no methods
• The initial class diagram developed during
the systems analysis phase includes no
methods. As behaviors of objects are
further developed (during analysis and
design) methods are added
24
RMO
Domain
Model
Class
Diagram
25
TA vs. OOA: Requirements modeling
• The requirements models are quite different depending
on approach used by the team: traditional or object-
oriented (the two key concepts – events and things)
• Traditional approach: based on the event table creates
a set of data flow diagrams (DFDs); the entity-relationship
diagram (ERD) defines the data storage requirements that
are included in the DFDs, views a system as a collection of
processes. When the process executes it interacts with
data. So, emphasizes processes, data, input/outputs
• Object Oriented approach: based on the event table
creates class diagrams, views a system as a collection of
interacting objects with their own behaviour (methods).
There are NO conventional processes and data files, just
interacting objects
26
Unified Modeling Language (UML)
By subsystem
By actor
32
Simple Use Case with an Actor
33
Use Case Diagram with
Automation Boundary and
Alternate Actor Notation
34
All Use Cases Involving Customer
as Actor
Direct access
to the system
35
A use case diagram
of the CSS for RMO
organizes by
subsystems
36
Use Cases of RMO Order Entry
Subsystem
39
Use Case Diagram vs. Structured
Techniques
• Objective of the use case diagram is to provide an overview of the
system (including actors and the functions they perform)
– A use case diagram is like a context diagram in the sense of
defining the scope of the system
– However, individual use cases appear more like a DFD fragment in
that they identify an individual function that the system must support
• Difference with structured techniques
– The use case diagram begins by defining the automation
boundary while in DFD this boundary is often not defined until the
entire process has been detailed
– In a DFD an external agent is always the original source or
destination of the information and may not necessarily be the one
interacting with the system;
– In a use case diagram, an actor is the one who actually
interacts with the system whether or not that actor is the original 40
source of information
Use Case Diagram vs. Structured
Techniques (cont’d)
Example: in the RMO case, a customer may call an RMO clerk
and make an order.
The DFD would identify the external entity as the customer; the
clerk’s activity would be embedded in a process “Enter customer
order”.
In the use case diagram, the clerk would be identified as the
actor who uses the system to enter or create a customer order
The use case diagram does not indicate data flows, i.e.
information flowing into and out of the system is not shown (this
is done with the next level of modeling – the sequence diagrams)
Important to identify every possible role that will use the
system.
41
Developing a Use Case Diagram
Two main approaches to developing a use case diagram:
First approach: start with an event table and analyze each event to
determine:
• How the system is used to support the event
• The actors who initiate the event
• Other use cases that will need to be invoked
• Generally, each event will become a use case
Second approach: identifying all the actors who use the system and the
EBPs with the user goal technique
Actors must actually contact the system
Assume perfect technology condition (no technical activities!)
Actors – are roles played by users (e.g., order clerk, manager)
Identify goal for each actor (e.g., “accept a return”)
42
Scenarios
• A use case only shows that an actor interacts with the system to carry
out a business activity
• There may be a whole series of individual steps to accomplish the use
case (these steps are described with a narrative called a flow of
activities) - steps within a use case
• A use case may have several alternative internal activities. In the RMO
example, for the use case “Create new order” there are at least two
sequences when:
– A customer creates telephone order through clerk (a clerk
interacts with the system), or
– A customer creates web order (a customer interacts with the
system)
• A particular sequence of activities within a use case is called
scenario. It represents a unique path through the use case
E.g., two possible scenarios for the RMO use case “Create new order”:
in the first instance, the second actor “Order clerk” is involved who is
actually interfacing with the system
43
Two scenarios for RMO
“Create new order”
44
Activity Diagrams
Used to document workflow of business process
activities for each use case or scenario
45
Activity
Diagram—
Telephone
Order
Scenario
46
Activity
Diagram—
Web Order
Scenario
47
Identifying Inputs and Outputs—
The System Sequence Diagram
Interaction diagram – a communication diagram or a
sequence diagram
System sequence diagram (SSD) is type of UML 2.0
interaction diagram
Used to model input and output messaging requirements
for a use case or scenario
Shows sequence of interactions as messages to/from actors
and internal objects during flow of activities
Emphasis: how the actor interacts with the system by
entering input data and receiving output data
Object notation instead of class notation is used to show
that message is sent to an individual object, not the class
System is shown as one object: a “black box”
48
Object and class names in SSD
49
SSD Notation
50
System Sequence Diagram (SSD)
Notation
51
SSD Notation
Activation line 52
SSD Lifelines
53
SSD Messages
55
Repeating
Message
56
Developing a System Sequence
Diagram
58
Resulting SSD for the Telephone
Order Scenario
59
SSD of the
Web Order
Scenario for
the Create
New Order
Use case
60
The relationship of use case
diagram, class diagram and
sequence diagrams
SSD includes objects from the class diagram and actors from the use
case diagram 61
Developing a System Sequence
Diagram: Steps
1. Identify all the objects and actors that are involved in the
scenario (they are only actors have been identified in the use
case diagram and objects from the classes that are identified
in the class diagram)
2. Based on the flow of activities, identify each message that
will be required to carry out the scenario along with both
source object (or actor) for the message and the destination
object (or actor)
3. Determine whether each message is always sent or sent only
under certain conditions
4. Sequence the messages correctly and attach them to the
appropriate lifelines of actors and objects
5. Add the formal syntax on the messages for conditions,
message names and passed parameters
6. Add response messages and communications 62
A complete
SSD for
the RMO
use case
Create new
order
63
Just for Fun!
http://www.visualjokes.com
64
Identifying Object Behaviour—
The State Machine Diagram (SMD)
SSDs give external view of object behaviour – messages
passed around but do not show, what an object does when it
gets a message
There is a need to specify internal logic for each object,
i.e., a description of the actions that the objects perform
themselves
State machine diagram is UML a 2.0 diagram that models
object internal behaviour, states and transitions
Complex problem domain classes can be modeled
67
State Machine Terminology
69
Concurrent Paths for Printer in
the On State
70
Relationships among OO models 71
State Machine Diagram and SSD
73
States and Exit Transitions for
OrderItem
74
Partial State Machine for
OrderItem
75
Final State Machine for OrderItem
76
Order Domain Class for RMO—
States and Exit Transitions
77
First-Cut State Machine Diagram
for Order
78
Second-Cut State Machine
Diagram for Order
79
Integrating Object-Oriented
Models
Complete use case diagram is needed to
understand total scope of new system
Domain model class diagrams should also be as
complete as possible for entire system
With iterative approach, construct use case
descriptions, activity diagrams, and system
sequence diagrams for use cases in iteration
Development of a new diagram often helps refine
and correct previous diagrams
80
Relationships Between OO
Requirements Models
81
Readings
!!
u!
yo
nk
82