schach5-chap12-14[1]

download schach5-chap12-14[1]

of 39

Transcript of schach5-chap12-14[1]

  • 8/14/2019 schach5-chap12-14[1]

    1/39

    Slide 12.1

    The McGraw-Hill Companies, 2002

    Object-Oriented andClassical Software

    Engineering

    Fifth Edition, WCB/McGraw-Hill, 2002

    Stephen R. [email protected]

  • 8/14/2019 schach5-chap12-14[1]

    2/39

    Slide 12.2

    The McGraw-Hill Companies, 2002

    CHAPTER 12

    OBJECT-ORIENTEDANALYSIS PHASE

  • 8/14/2019 schach5-chap12-14[1]

    3/39

    Slide 12.3

    The McGraw-Hill Companies, 2002

    Overview

    q Object-oriented analysis

    q Use-case modeling

    q Class modeling

    q Dynamic modeling

    q Testing during the object-oriented analysis phase

    q CASE tools for the object-oriented analysis phase

    q Air Gourmet case study: Object-oriented analysis

    q Challenges of the object-oriented analysis phase

  • 8/14/2019 schach5-chap12-14[1]

    4/39

    Slide 12.4

    The McGraw-Hill Companies, 2002

    Object-Oriented Analysis Phase

    q Object-oriented paradigm

    Reaction to perceived shortcomings in structured

    paradigm

    Problem of larger products

    Data and action treated as equal partners

  • 8/14/2019 schach5-chap12-14[1]

    5/39

    Slide 12.5

    The McGraw-Hill Companies, 2002

    Object-Oriented Paradigm

    q Object consists of

    Data (attributes, state variables, instance

    variables, fields, data members), and

    Actions (methods, member functions)

    q

    Objects are independent units Conceptual independence

    Physical independence

  • 8/14/2019 schach5-chap12-14[1]

    6/39

    Slide 12.6

    The McGraw-Hill Companies, 2002

    Object-Oriented Analysis (contd)

    q Semi-formal specification technique

    q Multiplicity of different methods

    Booch

    OMT

    Objectory Shlaer-Mellor

    Coad-Yourdon

    q All essentially equivalent

    q Nowadays, we represent OOA using UML

    (unified modeling language)

  • 8/14/2019 schach5-chap12-14[1]

    7/39

    Slide 12.7

    The McGraw-Hill Companies, 2002

    The Three Steps of OOA

    q 1. Use-case modeling

    Determine how the various results are computed by the

    product (without regard to sequencing)

    Largely action oriented

    q

    2. Class modeling (object modeling) Determine the classes and their attributes

    Purely data-oriented

    q 3. Dynamic modeling

    Determine the actions performed by or to each class

    Purely action-oriented

    q

    Iterative process

  • 8/14/2019 schach5-chap12-14[1]

    8/39

    Slide 12.8

    The McGraw-Hill Companies, 2002

    Elevator Problem: OOA

    q 1. Use-Case Modeling

    Use case: Generic description of overall functionality

    Scenario: Instance of a use case

    q Get comprehensive insight into behavior of

    product

  • 8/14/2019 schach5-chap12-14[1]

    9/39

    Slide 12.9

    The McGraw-Hill Companies, 2002

    Normal Scenario

  • 8/14/2019 schach5-chap12-14[1]

    10/39

    Slide 12.10

    The McGraw-Hill Companies, 2002

    Exception Scenario

  • 8/14/2019 schach5-chap12-14[1]

    11/39

    Slide 12.11

    The McGraw-Hill Companies, 2002

    Class Modeling

    q Extract classes and their attributes

    q Represent them using an entity-relationship

    diagram

    q Deduce the classes from use cases and their

    scenariosq Often there are many scenarios

    Possible danger: too many candidate classes

  • 8/14/2019 schach5-chap12-14[1]

    12/39

    Slide 12.12

    The McGraw-Hill Companies, 2002

    Two Approaches to Class Modeling

    q Noun extraction

    Always works

    q CRC classes

    Need to have domain expertise

  • 8/14/2019 schach5-chap12-14[1]

    13/39

    Slide 12.13

    The McGraw-Hill Companies, 2002

    Noun Extraction

    q 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.

  • 8/14/2019 schach5-chap12-14[1]

    14/39

    Slide 12.14

    The McGraw-Hill Companies, 2002

    Noun Extraction (contd)

    q 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;

    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.

  • 8/14/2019 schach5-chap12-14[1]

    15/39

    Slide 12.15

    The McGraw-Hill Companies, 2002

    Noun Extraction (contd)

    q Stage 3. Formalize the Strategy

    Identify nouns in informal strategy. Use nouns ascandidate classes

    q Nouns button, elevator, floor, movement, building, illumination,

    illumination, door floor, building, doorare outside problem boundary

    exclude

    movement, illumination, illumination are abstract nouns exclude (may become attributes)

    q Candidate classes: Elevatorand Buttonq Subclasses: Elevator ButtonandFloor Button

  • 8/14/2019 schach5-chap12-14[1]

    16/39

    Slide 12.16

    The McGraw-Hill Companies, 2002

    First Iteration of Class Diagram

    q Problem

    Buttons do not communicate directly with elevators

    We need an additional class:Elevator Controller

  • 8/14/2019 schach5-chap12-14[1]

    17/39

    Slide 12.17

    The McGraw-Hill Companies, 2002

    Second Iteration of Class Diagram

    q All relationships

    are now 1-to-n

    Makes design and

    implementation

    easier

  • 8/14/2019 schach5-chap12-14[1]

    18/39

    Slide 12.18

    The McGraw-Hill Companies, 2002

    CRC Cards

    q Used since 1989 for OOAq For each class, fill in card showing

    Name of class

    Functionality (responsibility)

    List of classes it invokes (collaboration)

    Now automated (CASE tool component)

    q Strength When acted out by team members, powerful

    tool for highlighting missing or incorrectitems

    q Weakness Domain expertise is needed

  • 8/14/2019 schach5-chap12-14[1]

    19/39

    Slide 12.19

    The McGraw-Hill Companies, 2002

    3. Dynamic Modeling

    q Produce UML state

    diagram

    q State, event, predicate

    distributed over state

    diagramq UML guards are in

    brackets

  • 8/14/2019 schach5-chap12-14[1]

    20/39

    Slide 12.20

    The McGraw-Hill Companies, 2002

    Testing during the OOA Phase

    q CRC cards are an excellent testing technique

  • 8/14/2019 schach5-chap12-14[1]

    21/39

    Slide 12.21

    The McGraw-Hill Companies, 2002

    CRC Cards

    q Consider responsibility 1. Turn on elevator button

    q Totally unacceptable for object-oriented

    paradigm

    q

    Responsibility-driven design ignoredq Information hiding ignored

    q Responsibility1. Turn on elevator button

    should be1. Send message to Elevator Button to turn itself on

  • 8/14/2019 schach5-chap12-14[1]

    22/39

    Slide 12.22

    The McGraw-Hill Companies, 2002

    CRC Cards (contd)

    q A class has been overlooked

    Elevator doors have a state that changes duringexecution (class characteristic)

    Add class Elevator Doors

    Safety considerations

    q Reconsider class modelq Then reconsider dynamic model, use-case

    model

  • 8/14/2019 schach5-chap12-14[1]

    23/39

    Slide 12.23

    The McGraw-Hill Companies, 2002

    Second Iteration of CRC Card

  • 8/14/2019 schach5-chap12-14[1]

    24/39

    Slide 12.24

    The McGraw-Hill Companies, 2002

    Third Iteration of Class Diagram

  • 8/14/2019 schach5-chap12-14[1]

    25/39

    Slide 12.25

    The McGraw-Hill Companies, 2002

    Second Iteration of Normal Scenario

  • 8/14/2019 schach5-chap12-14[1]

    26/39

    Slide 12.26

    The McGraw-Hill Companies, 2002

    Elevator Problem: OOA (contd)

    q All three models are now fineq We should rather say:

    All three models are fine for now

    q We may need to return to the object-oriented analysis phase during the object-oriented design phase

  • 8/14/2019 schach5-chap12-14[1]

    27/39

    Slide 12.27

    The McGraw-Hill Companies, 2002

    Why Is All This Iteration Needed?

    q Perhaps the method is not yet mature?

    Waterfall model (explicit feedback loops)

    Rapid prototyping model (aim: to reduce iteration)

    Incremental model, and

    Spiral modelq Latter two explicitly reflect iterative approach

    q Iteration is an intrinsic property of all software

    production

    Especially for medium- and large-scale products

    Expect iteration in the object-oriented paradigm

  • 8/14/2019 schach5-chap12-14[1]

    28/39

    Slide 12.28

    The McGraw-Hill Companies, 2002

    CASE tools for OOA phase

    q Diagrams play a major roleq Diagrams often change

    Need a diagramming tool

    Many tools go further

    q All modern tools support UML Example

    Rose

  • 8/14/2019 schach5-chap12-14[1]

    29/39

    Slide 12.29

    The McGraw-Hill Companies, 2002

    Air Gourmet Case Study: OOA

    q

    Use-case model for making a reservation

  • 8/14/2019 schach5-chap12-14[1]

    30/39

    Slide 12.30

    The McGraw-Hill Companies, 2002

    Making a Reservation: Extended Scenario

  • 8/14/2019 schach5-chap12-14[1]

    31/39

    Slide 12.31

    The McGraw-Hill Companies, 2002

    Air Gourmet Case Study: OOA

    q Use-case for returning and scanning a postcard

  • 8/14/2019 schach5-chap12-14[1]

    32/39

    Slide 12.32

    The McGraw-Hill Companies, 2002

    Postcards: Extended Scenario

  • 8/14/2019 schach5-chap12-14[1]

    33/39

    Slide 12.33

    The McGraw-Hill Companies, 2002

    Air Gourmet Case Study: Class Modeling

    q 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.

    ( )

  • 8/14/2019 schach5-chap12-14[1]

    34/39

    Slide 12.34

    The McGraw-Hill Companies, 2002

    (contd)

    q 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.

    ( td)

  • 8/14/2019 schach5-chap12-14[1]

    35/39

    Slide 12.35

    The McGraw-Hill Companies, 2002

    (contd)

    q Stage 3. Formalize the Strategy

    Identify nouns in informal strategy. Use nouns as

    candidate classes

    q Nouns report, efficacy, program, percentage, meal, flight, boarding,

    passenger, name, address, quality

    efficacy, program, percentage, boarding, quality are abstract

    nouns exclude (may become attributes)

    name, address are attributes ofpassenger

    Question: Should meal and flight be classes?

    q It is easier to add classes than to remove them

    q Candidate classes: Report and Passenger

    Fi t It ti f Cl Di )

  • 8/14/2019 schach5-chap12-14[1]

    36/39

    Slide 12.36

    The McGraw-Hill Companies, 2002

    First Iteration of Class Diagram)

    q

    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

    S d It ti f Cl Di ( td)

  • 8/14/2019 schach5-chap12-14[1]

    37/39

    Slide 12.37

    The McGraw-Hill Companies, 2002

    Second Iteration of Class Diagram (contd)

    q Cause of our

    problems Flight should

    have been a

    candidate

    class

    q BUT, we all

    have 2020

    hindsight

    Ai G t C St d D i M d l

  • 8/14/2019 schach5-chap12-14[1]

    38/39

    Slide 12.38

    The McGraw-Hill Companies, 2002

    Air Gourmet Case Study: Dynamic Model

    q State diagram

    Ch ll f th OOOA Ph

  • 8/14/2019 schach5-chap12-14[1]

    39/39

    Slide 12.39Challenges of the OOOA Phase

    q Do not class the boundary into object-oriented

    designq Do not allocate methods to classes yet