Software Engineering Requirements Engineering

Download Report

Transcript Software Engineering Requirements Engineering

Object-Oriented Modeling
Using UML (2)
CS 3331
Fall 2009
1
Outline

Modeling dynamic behavior



Statechart diagram
Sequence diagram
Modeling requirements

Use case diagram
2
Modeling Dynamic Behavior

Statechart diagram



Depicts the flow of control using states and
transitions
Generalization of finite state machines
Sequence diagram

Depicts object interaction by highlighting the
time ordering of method invocations
3
Statechart Diagram



Graph representing finite state machine
Network of states and transitions
Good for modeling reactive systems
push switch
On
Off
push switch
4
Elements of Statechart
Final State
Initial State
Transition
Running
Idle
State
5
State

Condition or situation in the life of a system (or
object) during which it:




Satisfies some condition,
Performs some activity, or
Waits for some events.
Set of values of properties that affect the
behavior of the system (or object).


Determines response to an event,
Thus, different states may produce different
responses to the same event
6
Transition

Relationship between two states indicating that
a system (or object) in the first state will:



Perform certain actions and
Enter the second state when specified event occurs
and specified condition is satisfied.
Consists of:


Source and target states
Optional event, guard condition, and action
Event [Condition] / Action
Source
Target
7
Definition

Event



An occurrence of a stimulus that can trigger a state
transition
Instantaneous and no duration
Action

An executable atomic computation that results in a
change in state of the model or the return of a value
8
Example
dial digit(n)
[incomplete]
connected
Connecting
Dialing
dial digit(n)
[invalid]
Ringing
dial digit(n)
[valid] / connect
busy
Busy
Invalid
9
Another Example
recovery success
recovery failure
anomaly
Recovery
Identification
Normal
temperature
pressure
recovery
failure
recovery
success
Pressure
Recovery
Temperature
Recovery
recovery
failure
recovery success
10
Composite States
anomaly
Recovery
Recovery
Identification
Normal
recovery
success
recovery
failure
pressure
Pressure
Recovery
temperature
Temperature
Recovery
11
Composite States (Cont.)





Used to simplify diagrams
Inside, looks like statechart
May have composite transitions
May have transitions from substates
Sequential and parallel
12
Composites and Transitions
Transition to/from composite state
Active
Idle
Validating
Selecting
Processing
Maintenance
Printing
Transition from substate
13
Including Composite States
Dial Number
Include / Dialing
Dialing
[number.isValid()]
Start
entry / start dial tone
exit / end dial tone
digit(n)
Partial Dialing
entry / number.append(n)
digit(n)
14
Parallel Composition


Concurrency (split of control)
Synchronization
Superstate
substate1
substate2
substate3
substate4
15
Example
Incomplete
HW1
HW2
Passed
Project
Midterm
Final
fail
Failed
16
Group Exercise: Cellular Phone

Draw a statechart describing the operation of
a cellular phone. Assume that the cellular
phone has keys for:




power on and off
keypad locking and unlocking
0-9, #, and *
talk (or send) and end
Model at least the following operations:




power on/off
keypad locking/unlocking
making calls (e.g., dialing, connecting, talking),
receiving calls (e.g., ringing, talking)
17
Outline

Modeling dynamic behavior



Statechart diagram
Sequence diagram
Modeling requirements

Use case diagram
18
Sequence Diagram


Describes a sequence of method calls
among objects
Highlights the time ordering of method
calls
19
Example
: Customer
object
: Order
: Payment
: Product
: Supplier
place an order
process
control
lifetime
validate
if ( payment ok )
deliver
if ( not in stock )
back order
g et addres s
mail to address
message
20
Example (Cont.)
: Customer
: Order
: Payment
: Product
: Supplier
place an order
process
validate
Sequence of message sending
if ( payment ok )
deliver
if ( not in stock )
back order
g et addres s
mail to address
21
Collaboration Diagram
object
1.1 : ok := validate()
: Order
: Payment
link
1.2 [ok] : deliver(c)
1 : place an order(c)
c : Customer
1.2.2 : g et address()
p : Product
1.2.1 [not in stock] : back order(p)
message
: Supplier
22
Collaboration Diagram
Collaboration
1.1 : ok := validate()
: Order
: Payment
1.2 [ok] : deliver(c)
1 : place an order(c)
c : Customer
1.2.2 : g et address()
p : Product
1.2.1 [not in stock] : back order(p)
: Supplier
23
Outline

Modeling dynamic behavior



Statechart diagram
Sequence diagram
Modeling requirements

Use case diagram
24
Modeling Requirements

Use case diagram


Describes the externally observable behavior
of system functions, usually to define system
requirements
Describes interactions between the system
and external entities
25
Example: Goldmine
system
boundary
use case
Register
actor
Student
Check
Grades
<<include>>
Validate User
26
Elements of Use Case Diagram

Actor:


Use case:



represents a role played by external entities that
interact with the system
Describes what the system does (i.e., functionality)
Scenario: sequence of interactions between the
actors and the system
Relationship:



Extension (or generalization) among actors
Association between actors and use cases
Dependency among use cases: include and extend
27
Example: Goldmine (Cont.)
Register
User
Check Grades
<<include>>
User
Validate User
Student
Get Roster
<<include>>
<<extend>>
Student
Faculty
Faculty
Enter Grades
28
Use Case Scenarios
Use Case: Check Grades
Description: View the grades of a specific year and semester
Actors: Student
Precondition: The student is already registered
Main scenario:
User
System
1. The system carries out “Validate User”, e.g.,
for user “miner” with password “allAs”.
2. The system prompts for the year and semester.
3. The user enters the year and
semester, e.g., Fall 2007.
4. The system displays the grades of the courses
taken in the given semester, i.e., Fall 2007.
Alternative:
The student enters “All” for the year and semester, and the system displays
grades of all courses taken so far.
Exceptional:
The “Validate User” use case fails; the system repeats the validation use case.
29
Group Exercise: E-book Store
Identify the main actors and the key use cases for an e-bookstore,
and draw a use case diagram. Describe the use case scenario for
the most important use case.
The core requirements of the e-bookstore are to allow its
customers to browse and order books, music CDs, and computer
software through the Internet. The main functionalities of the
system are to provide information about the titles it carries to help
customers make purchasing decisions; handle customer
registration, order processing, and shipping; and support
management of the system, such as adding, deleting, and
updating titles and customer information.
30