Slides - Gustavus Adolphus College

advertisement
MCS 270 Spring 2014
Object-Oriented Software Development
MCS 270 Object-Oriented Software Development
Today’s schedule
Interaction Modeling:
Use Case Model
Sequence Model
Activity Model
Adapted from Software Engineering, Spring 2006, NYU
http://cs.nyu.edu/courses/spring06/V22.0474-001
GUSTAVUS ADOLPHUS COLLEGE
gustavus.edu
MCS 270 Object-Oriented Software Development
Unified modeling language (UML)
Class model: describes the static structure of objects
and relationships in a system
Comprises object and class diagrams
State model: describes the dynamic aspects (life
cycles) of objects and the nature of control in a
system
Interaction model: describes how objects in a system
interact to achieve broader results
GUSTAVUS ADOLPHUS COLLEGE
gustavus.edu
MCS 270 Object-Oriented Software Development
Interaction Modeling: Use Cases
A use case names a type of user (actor) and
something that they want to do (usecase).
An actor is an external user of a system. Can be
a human, a device, or a piece of software.
The use case describes how an actor achieves a
specific tangible goal.
GUSTAVUS ADOLPHUS COLLEGE
gustavus.edu
MCS 270 Object-Oriented Software Development
Interaction Modeling: Use Cases
Usecase can consist of:
Textual Description: Name, Summary, Actors,
Entry conditions, Exit conditions, Exceptions or
Errors, Event-Flow Description
UseCase Diagram: Graphical (Brief!) summary
of use case
GUSTAVUS ADOLPHUS COLLEGE
gustavus.edu
MCS 270 Object-Oriented Software Development
Example: Use-Case Description
Name: Normal Subway Ride
Summary: A passenger takes a subway ride
Actors: Passenger
Entry Condition: Passenger at start station
Exit Condition: Passenger leaves end station
Exceptions: Out of tickets, Train in repair, Train Derail,
Door won’t open, Miss stop station
GUSTAVUS ADOLPHUS COLLEGE
gustavus.edu
MCS 270 Object-Oriented Software Development
Example: Use-Case Description
Event-flow Description
Passenger purchases ticket/has pre-purchased ticket
Train arrives and stops at platform
Doors open
Passenger steps into train
Doors close
Passenger presses request button for final stop
Doors open at final stop
Passenger exits train
GUSTAVUS ADOLPHUS COLLEGE
gustavus.edu
MCS 270 Object-Oriented Software Development
Example: Use Case Diagram
Boundary for all use cases
Graph showing
Actors
Use cases
Ride
Edge: actor-case if that
actor is involved in that
case
passeng
er
Actors
Repai
r
Stick figures
Use cases
Ovals
GUSTAVUS ADOLPHUS COLLEGE
technicia
n
gustavus.edu
MCS 270 Object-Oriented Software Development
Exceptional Situations
Include relationships
“Buy Ticket” use case is included in Ride use case.
Extend relationships
Expresses an exceptional variation of a use case
Normally used to express errors
GUSTAVUS ADOLPHUS COLLEGE
gustavus.edu
MCS 270 Object-Oriented Software Development
Ride
<<extend>>
passeng
er
technicia
n
GUSTAVUS ADOLPHUS COLLEGE
<<include>>
Buy
Ticket
Derail
Repai
r
gustavus.edu
MCS 270 Object-Oriented Software Development
Summary of Use Cases
Use Case Diagram
Shows all actors, use cases, relationships
Actors are agents external to the system
Use Case Description – information for single Use case
Entry/Exit Conditions, Story, Main and Alternative Event flows, Exceptions
Specified in a separate document
Report style – complete sentences, etc
GUSTAVUS ADOLPHUS COLLEGE
gustavus.edu
MCS 270 Object-Oriented Software Development
Interaction Modeling: Sequence Model
Sequences elaborate Use Cases - consist of:
Textual Scenario: Sequence of events
occurring a specific event sequence in a
system (could be a use case)
Sequence Diagram: Graphical summary of
participants (Actors, Objects) and messages
between participants through time
GUSTAVUS ADOLPHUS COLLEGE
gustavus.edu
MCS 270 Object-Oriented Software Development
Sequence Diagram
Sequence Diagram is a table
Columns are classes or actors (lifelines)
Rows are time steps (time flows from top to bottom)
Horizontal Arrows show control/data flow
Method calls
Important changes in state
Specific Diagram for each task
GUSTAVUS ADOLPHUS COLLEGE
gustavus.edu
MCS 270 Object-Oriented Software Development
Example Sequence Diagram
Passeng
Station
Trai
er buyTicket()
n
arrives
Classes &
Actors
openDoors()
closeDoors()
pushButton(S)
GUSTAVUS ADOLPHUS COLLEGE
gustavus.edu
MCS 270 Object-Oriented Software Development
Example Sequence Diagram
Passeng
Station
Trai
er buyTicket()
n
arrives
openDoors()
closeDoors()
pushButton(S)
GUSTAVUS ADOLPHUS COLLEGE
Method Call
Note: These
are all
synchronous
method
calls. There
are other
kinds of
invocations.
gustavus.edu
MCS 270 Object-Oriented Software Development
Example Sequence Diagram
Passeng
Station
Trai
er buyTicket()
n
arrives
openDoors()
closeDoors()
Invocation
lifetime
spans
lifetimes of
all nested
invocations
pushButton(S)
GUSTAVUS ADOLPHUS COLLEGE
gustavus.edu
Example Sequence Diagram
Passeng
Station
Trai
er buyTicket()
n
arrives
openDoors()
“Lifelines”
fill in time
between
invocations
closeDoors()
pushButton(S)
GUSTAVUS ADOLPHUS COLLEGE
gustavus.edu
MCS 270 Object-Oriented Software Development
Interaction Modeling: Activity Model
Activity Model consists of:
Activity Diagram: Flow Chart of operations
of application
GUSTAVUS ADOLPHUS COLLEGE
gustavus.edu
MCS 270 Object-Oriented Software Development
Example Activity Diagram
Station
Activities
in
roundtangl
es
Train
buyTicket
trainArrive
GUSTAVUS ADOLPHUS COLLEGE
board
gustavus.edu
MCS 270 Object-Oriented Software Development
Example Activity Diagram
Station
Train
buyTicket
Fork
trainArrive
Concurren
cy
board
Join
GUSTAVUS ADOLPHUS COLLEGE
gustavus.edu
MCS 270 Object-Oriented Software Development
Example Activity Diagram
Swim lanes
show which
classes/actors
are responsible
for which part of
the diagram
Station
buyTicket
trainArrive
GUSTAVUS ADOLPHUS COLLEGE
Train
board
gustavus.edu
MCS 270 Object-Oriented Software Development
Example Activity Diagram
Flow-chart ifthen
StopRequested?
yes
stopTrain
GUSTAVUS ADOLPHUS COLLEGE
no
announceNoStop
gustavus.edu
MCS 270 Object-Oriented Software Development
Overview on Using UML: What’s Good
A common language
Makes it easier to share requirements, specs, designs
Visual syntax is useful, to a point
A picture is worth 1000 words
For the non-programmer, easier to grasp simple diagrams
than simple code/pseudo-code
To the extent UML is precise, forces clarity
Much better than natural language
Commercial tool support
Tools for UML -> code or vice-versa
GUSTAVUS ADOLPHUS COLLEGE
gustavus.edu
MCS 270 Object-Oriented Software Development
Overview on Using UML: What’s Not so Good
Hodge-podge of ideas
Union of most popular modeling languages
Visual syntax does not scale well
Many details are hard to depict visually
Ad hoc text attached to diagrams
No visualization advantage for large diagrams
1000 pictures are very hard to understand
Semantics is not completely clear
Some parts of UML underspecified, inconsistent
GUSTAVUS ADOLPHUS COLLEGE
gustavus.edu
MCS 270 Object-Oriented Software Development
Why use UML?
UML is being widely adopted
By users
By tool vendors
By programmers
A step forward
Better than just diving in and coding!
First standard for high-levels of software process
Expect further evolution, development of UML
GUSTAVUS ADOLPHUS COLLEGE
gustavus.edu
MCS 270 Object-Oriented Software Development
Suggestions on using UML
Discovering Requirements for Code
Use Case Diagrams/Descriptions to illustrate use cases
Activity or Sequence Diagrams to illustrate typical flow within a use case
(scenarios)
Design
Class Diagram for system architecture
GUSTAVUS ADOLPHUS COLLEGE
gustavus.edu
MCS 270 Object-Oriented Software Development
Use Case Exercise
Groups of 3-4: Create a Use Case analysis of “GusList” – an on-line classified
ad service for the Gustavus community.
Ideal: Design use cases in conversation with users (Students, Faculty, Staff)
Next Best – You will practice this in conversation with each other.
Task: Identify
Actors
Use Case Names (General)
By next Tuesday, prepare (individually) a Requirements statement and a use
case document.
Document contains: Requirements statement. Use Case diagram(s). At least
two fully developed Textual Descriptions.
GUSTAVUS ADOLPHUS COLLEGE
gustavus.edu
MCS 270 Object-Oriented Software Development
Assignments
Friday – Read Chapters 10,11
Continue GusList Use Case Project
Homework: Chapter 5. Exercises 5.3, 5.4
Programming: Interfaces
Due Tomorrow: Friday, Feb. 21
GUSTAVUS ADOLPHUS COLLEGE
gustavus.edu
Download