Title: ObjectOriented and Classical Software Engineering Fifth Edition, WCBMcGrawHill, 2002 Stephen R' Scha
1Object-Oriented and Classical Software
Engineering Fifth Edition, WCB/McGraw-Hill,
2002Stephen R. Schachsrs_at_vuse.vanderbilt.edu
2CHAPTER 12
OBJECT-ORIENTED ANALYSIS PHASE
3Overview
- Object-oriented analysis
- Use-case modeling
- Class modeling
- Dynamic modeling
- Testing during the object-oriented analysis phase
- CASE tools for the object-oriented analysis phase
- Air Gourmet case study Object-oriented analysis
- Challenges of the object-oriented analysis phase
4Object-Oriented Analysis Phase
- Object-oriented paradigm
- Reaction to perceived shortcomings in the
structured paradigm - The problem of larger products
- Data and action are treated as equal partners
5Object-Oriented Paradigm
- Object consists of
- Data (attributes, state variables, instance
variables, fields, data members), and - Actions (methods, member functions)
- Objects are independent units
- Conceptual independence
- Physical independence
6Object-Oriented Analysis (contd)
- Semi-formal specification technique
- Multiplicity of different methods
- Booch
- OMT
- Objectory
- Shlaer-Mellor
- Coad-Yourdon
- All are essentially equivalent
- Nowadays, we represent OOA using UML (Unified
Modeling Language)
7The Three Steps of OOA
- 1. Use-case modeling
- Determine how the various results are computed by
the product (without regard to sequencing) - Largely action-oriented
- 2. Class modeling (object modeling)
- Determine the classes and their attributes
- Purely data-oriented
- 3. Dynamic modeling
- Determine the actions performed by or to each
class - Purely action-oriented
- Process is iterative
8Elevator Problem OOA
- 1. Use-Case Modeling
- Use case Generic description of overall
functionality - Scenario Instance of a use case
- Get comprehensive insight into behavior of product
9Normal Scenario
10 Exception Scenario
11 Class Modeling
- Extract classes and their attributes
- Represent them using an entity-relationship
diagram - Deduce the classes from use cases and their
scenarios - Often there are many scenarios
- Possible danger too many candidate classes
12Two Approaches to Class Modeling
- Noun extraction
- Always works
- CRC cards
- Need to have domain expertise
13Noun Extraction
- Stage 1. Concise Problem Definition
- Define product in single sentence
- Buttons in elevators and on the floors control
the motion of n elevators in a building with m
floors.
14Noun Extraction (contd)
- Stage 2. Informal Strategy
- Incorporate constraints, express result in a
single paragraph - Buttons in elevators and on the floors control
movement of n elevators in a building with m
floors. Buttons illuminate when pressed to
request the elevator to stop at a specific floor
the illumination is canceled when the request has
been satisfied. When an elevator has no
requests, it remains at its current floor with
its doors closed.
15Noun Extraction (contd)
- Stage 3. Formalize the Strategy
- Identify nouns in the informal strategy. Use
nouns as candidate classes - Nouns
- button, elevator, floor, movement, building,
illumination, request, door - floor, building, door are outside problem
boundary exclude - movement, illumination, request are abstract
nouns exclude (they may become attributes) - Candidate classes Elevator and Button
- Subclasses Elevator Button and Floor Button
16First Iteration of Class Diagram
- Problem
- Buttons do not communicate directly with
elevators - We need an additional class Elevator Controller
17Second Iteration of Class Diagram
- All relationships are now 1-to-n
- This makes design and implementation easier
18CRC Cards
- Used since 1989 for OOA
- For each class, fill in card showing
- Name of Class
- Functionality (Responsibility)
- List of classes it invokes (Collaboration)
- Now automated (CASE tool component)
- Strength
- When acted out by team members, CRC cards are a
powerful tool for highlighting missing or
incorrect items - Weakness
- Domain expertise is needed
193. Dynamic Modeling
- Produce UML state diagram
- State, event, predicate are distributed over the
state diagram - UML guards are in brackets
20Testing during the OOA Phase
- CRC cards are an excellent testing technique
21CRC Cards
- Consider responsibility
- 1. Turn on elevator button
- Totally unacceptable for the object-oriented
paradigm - Responsibility-driven design has been ignored
- Information hiding has been ignored
- Responsibility
- 1. Turn on elevator button
- should be
- 1. Send message to Elevator Button to turn
itself on
22CRC Cards (contd)
- A class has been overlooked
- Elevator doors have a state that changes during
execution (class characteristic) - Add class Elevator Doors
- Safety considerations
- Reconsider the class model
- Then reconsider the dynamic model and the
use-case model
23Second Iteration of CRC Card
24Third Iteration of Class Diagram
25Second Iteration of Normal Scenario
26Elevator Problem OOA (contd)
- All three models are now fine
- We should rather say
- All three models are fine for now
- We may need to return to the object-oriented
analysis phase during the object-oriented design
phase
27Why Is All This Iteration Needed?
- Perhaps the method is not yet mature?
- Waterfall model (explicit feedback loops)
- Rapid prototyping model (aim to reduce
iteration) - Incremental model (explicit iterative approach)
- Spiral model (explicit iterative approach)
- Iteration is an intrinsic property of all
software production - Especially for medium- and large-scale products
- Expect iteration in the object-oriented paradigm
28CASE Tools for OOA phase
- Diagrams play a major role
- Diagrams often change
- Need a diagramming tool
- Many tools go further
- All modern tools support UML
- Example
- Rose
29Air Gourmet Case Study OOA
- Use-case model for making a reservation
30Making a Reservation Extended Scenario
31Air Gourmet Case Study OOA
- Use-case for returning and scanning a postcard
32Postcards Extended Scenario
33Air Gourmet Case Study Class Modeling
- Stage 1. Concise Problem Definition
- Define product in single sentence
- A computerized system is needed to provide
information regarding the efficacy of a special
meals program.
34Air Gourmet Case Study Noun Extraction (contd)
- Stage 2. Informal Strategy
- Incorporate constraints, express result in a
single paragraph - Reports are to be generated to document the
efficacy of the special meals program. The
reports concern meals loaded on flights, flights
boarded by passengers, names and addresses of
passengers, meal quality, and low-sodium meals.
35Air Gourmet Case Study Noun Extraction (contd)
- Stage 3. Formalize the Strategy
- Identify nouns in informal strategy. Use nouns
as candidate classes - Nouns
- report, efficacy, program, percentage, meal,
flight, boarding, passenger, name, address,
quality - efficacy, program, percentage, boarding, quality
are abstract nouns exclude (they may become
attributes) - name, address are attributes of passenger
- Question Should meal and flight be classes?
- It is easier to add classes than to remove them
- Candidate classes Report and Passenger
36First Iteration of Class Diagram)
- Problems with this class diagram
- Data for reports are needed on a per-flight basis
- Each report has to access multiple flights
- Each flight has multiple passengers
- Six reports (not four) are needed
37Second Iteration of Class Diagram (contd)
- Cause of our problems
- Flight should have been a candidate class
- BUT, we all have 2020 hindsight
38Air Gourmet Case Study Dynamic Model
39Challenges of the OOA Phase
- Do not cross the boundary into object-oriented
design - Do not allocate methods to classes yet