object-oriented analysis

41
CS3320::CH11 1 OBJECT-ORIENTED ANALYSIS Chapter 11

Upload: colin-vega

Post on 04-Jan-2016

76 views

Category:

Documents


1 download

DESCRIPTION

OBJECT-ORIENTED ANALYSIS. Chapter 11. OBJECT-ORIENTED ANALYSIS (OOA). Semi-formal specification technique Several methods Booch, OMT, OOSE, Objectory--Essentially equivalent Nowadays--represent OOA using UML (Unified Modeling Language). THE THREE STEPS OF OOA. 1. Use-case Modeling - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: OBJECT-ORIENTED ANALYSIS

CS3320::CH11 1

OBJECT-ORIENTED ANALYSIS

Chapter 11

Page 2: OBJECT-ORIENTED ANALYSIS

CS3320::CH11 2

OBJECT-ORIENTED ANALYSIS (OOA)• Semi-formal specification technique• Several methods

– Booch, OMT, OOSE, Objectory--Essentially equivalent

– Nowadays--represent OOA using UML (Unified Modeling Language)

Page 3: OBJECT-ORIENTED ANALYSIS

CS3320::CH11 3

THE THREE STEPS OF OOA1. 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 and to each class

– Purely action-oriented

Page 4: OBJECT-ORIENTED ANALYSIS

CS3320::CH11 4

Elevator Problem:OOA

1. Use-case Modeling• Use cases: Describe the behavior of the system

as seen from actor’s point of view.• Actors: external entities that interact with the

system (e.g. A system adm, a bank customer, a bank teller, a central database, etc.)

• A Scenario: a concise description of how an actor may interact with the system– a scenario is an instance of a use case

Page 5: OBJECT-ORIENTED ANALYSIS

CS3320::CH11 5

1. Use-case Modeling

• Identify the actors• Identify a list of "typical" scenarios to get

insight into the system’s behavior• Identify use-cases

– a use-case specifies all possible scenarios for a given functionality.

– a use case is initiated by an actor. – A use case represents a flow of events thru

the system.

Page 6: OBJECT-ORIENTED ANALYSIS

CS3320::CH11 6

Elevator Problem: OOA

Page 7: OBJECT-ORIENTED ANALYSIS

CS3320::CH11 7

Normal Scenario

Page 8: OBJECT-ORIENTED ANALYSIS

CS3320::CH11 8

Abnormal Scenario

Page 9: OBJECT-ORIENTED ANALYSIS

CS3320::CH11 9

2. Object Modeling• The object model describes the real-world object

classes of the systems and their relationship to each other with an entity-relationship diagram

• It shows the static structure of the system.

1. Identify classes/objects

2. Identify associations between objects

3. Identify attributes of objects

4. Represent them using an entity-relationship diagram

5. Prepare a data dictionary

Page 10: OBJECT-ORIENTED ANALYSIS

CS3320::CH11 10

Identifying Object Classes

• An Object is an instance of a class that consists of– Data (attributes, state variables, instance

variables, fields, data members)– Actions (methods , member functions)

• An object has a state (represented by data members) that changes during execution.

Page 11: OBJECT-ORIENTED ANALYSIS

CS3320::CH11 11

Identifying Object Classes

• Objects include physical entities (house, employees, button, etc.) and concepts (payment schedule, seating assignment, trajectory, etc.)

• Avoid computer implementation constructs (an array, a linked list, a binary tree, etc.)

• Don’t be concerned with operations at this points.

Page 12: OBJECT-ORIENTED ANALYSIS

CS3320::CH11 12

Identifying Object Classes

• Two approaches– Deduce from use cases and their scenarios

• often many scenarios

• too many candidate classes

– Noun Extraction

• The two approaches are complementary

Page 13: OBJECT-ORIENTED ANALYSIS

CS3320::CH11 13

Noun ExtractionStage 1: Concise Problem Definition• Define product in a single sentence

Buttons in elevators and floors are to be used to control motion of n elevators in building with m floors.

Stage 2: Incorporate constraints

buttons illuminate when pressed to request elevator to stop at specific floor; illumination is cancelled when request has been satisfied. If elevator has no requests, it remains at its current floor with its doors closed.

Page 14: OBJECT-ORIENTED ANALYSIS

CS3320::CH11 14

Noun Extraction

Stage 3: Identify nouns.

Nouns: buttons, elevator, floor, movement, building, illumination, door

• floor, building, door are outside the problem boundary==>excluded

• Movement, illumination are abstract nouns ==>excluded (may become attributes)

• Candidate classes: elevator, button• Subclasses: Elevator button and floor button

Page 15: OBJECT-ORIENTED ANALYSIS

CS3320::CH11 15

Noun ExtractionPart of Speech Model

ComponentExamples

Common Noun Class Teacher

Proper noun Object Alice

Doing verb Operation Creates,submits, selects

Being verb Inheritance Is a kind of, isone of either

Having verb Aggregation Has, consists of,includes

Modal verb Constraint Must be

Page 16: OBJECT-ORIENTED ANALYSIS

CS3320::CH11 16

Identify Associations• An association is any dependency between two

or more classes. • Example:

– Person works-for Company– User has Home Directory– Directory contains Files

• contains and part-of are special types of associations called aggregation

• Inheritance is also a special type of association.

Page 17: OBJECT-ORIENTED ANALYSIS

CS3320::CH11 17

Identifying Associations

• Problem statement– location phrases: next to, contained in, etc– communication: talk to– ownership phrases: has, part of– satisfaction of some condition: works for,

married to, manages

• Some depend on knowledge of application domain.

Page 18: OBJECT-ORIENTED ANALYSIS

CS3320::CH11 18

Identifying Associations

Example: Buttons in elevators and floors are to be used to control motion of n elevators in building with m floors.

– Buttons control elevators– There are two types of buttons: floor buttons

and elevator buttons– However, buttons do not really control

elevator they simply communicate with it.

Page 19: OBJECT-ORIENTED ANALYSIS

CS3320::CH11 19

Identify Associations

• Identify association multiplicity:– 1 to 1– 1 to many– Many to many

• Identify aggregations• Identify inheritance relations

Page 20: OBJECT-ORIENTED ANALYSIS

CS3320::CH11 20

First Iteration of Class Model

• Problem: buttons do not communicate directly with elevator==> class Elevator Controller

Page 21: OBJECT-ORIENTED ANALYSIS

CS3320::CH11 21

Second Iteration of Class Model

Page 22: OBJECT-ORIENTED ANALYSIS

CS3320::CH11 22

Identify Attributes• Attributes are properties of individual objects

Problem Statement:– Correspond to nouns followed by possessive

phrase: collar of the car, position of the cursor, salary of the employee, etc.

• Attributes are less likely to occur in statement of the problem. Knowledge of application domain.

• Try to get only the most important attributes at this stage. Others can be added later

Page 23: OBJECT-ORIENTED ANALYSIS

CS3320::CH11 23

Prepare Data Dictionary

• Write a paragraph describing each object class. Described the scope of the class within the current problem

• Describe associations and attributes• Data dictionaries also include description of

operations.

Page 24: OBJECT-ORIENTED ANALYSIS

CS3320::CH11 24

CRC Cards

Used since 1989 for OOA• For each class, fill in card showing

– name of Class– Responsibility : functionality– Collaboration: list of classes it invokes

Page 25: OBJECT-ORIENTED ANALYSIS

CS3320::CH11 25

Elevator Controller--CRC

1. Turn on elevator button

Totally unacceptable in OOA

Page 26: OBJECT-ORIENTED ANALYSIS

CS3320::CH11 26

Elevator Controller--CRC

1. Turn on Elevator Button

Should be

1. Send message to Elevator Button to turn on button

What about ?

5. Open elevator doors• Note: Elevator doors have a state that changes

during execution (class characteristic)• ==> add class Elevator Doors

Page 27: OBJECT-ORIENTED ANALYSIS

CS3320::CH11 27

Elevator Controller--CRC

Page 28: OBJECT-ORIENTED ANALYSIS

CS3320::CH11 28

3. Dynamic Modeling

• The dynamic model shows the time-dependent behavior of the system

Aim:• Produce a UML state diagram for each object

class.• A state diagram is less formal than an FSM

– States, events, and conditions

Page 29: OBJECT-ORIENTED ANALYSIS

CS3320::CH11 29

States and Events

• The state of an object are defined by the values of its attributes.

• Objects change state when stimulated by other objects or external actors.

• A event is an individual stimulus from one object to another.

• The response to an event by the object receiving it can include a change of state or the sending of an another event (to the original object or another object)

Page 30: OBJECT-ORIENTED ANALYSIS

CS3320::CH11 30

Events• An event is something that happens at a point in

time: user depresses left-button, phone receiver lifted, call is routed, input string entered.

• An event has no duration: assumed to be instantaneous

• An event coveys information from one object to another– signal that something has occurred– Send data values:

• left mouse-button pushed (location)

Page 31: OBJECT-ORIENTED ANALYSIS

CS3320::CH11 31

Example

• Draw a state diagram for a phone line

Page 32: OBJECT-ORIENTED ANALYSIS

CS3320::CH11 32

Conditions• A condition is a Boolean function of an object

values. Example:– Temperature is below freezing– Floor button is lit– No cars on N/S left lanes

• A condition is valid over an interval of time• Generally, a condition indicates the state of

another object in the system.

Page 33: OBJECT-ORIENTED ANALYSIS

CS3320::CH11 33

Conditions

• Conditions are used as guards on transitions:– A transition fires when its event occurs, only

if the guard condition is true

– When you go out in the morning (event), if the temperature is below freezing (condition), then put on your gloves (next state)

Page 34: OBJECT-ORIENTED ANALYSIS

CS3320::CH11 34

Traffic Light Controller

• Straight N/S or W/E• After N/S times-out,

– if there are cars on N/S left lane, N/E left-turn signal is turned on

– else straight W/E light is turned on

• Same for W/E left-lane

Page 35: OBJECT-ORIENTED ANALYSIS

CS3320::CH11 35

N/S may go straight N/S may turn

left

W/E may go straight

W/E may turn left Time-out

[cars in W/E left lane]

Time-out

Time-out[cars in N/S left lane]

Time-out[No cars in N/S left lane]

Time-out

Time-out[No cars in W/E left lane]

Page 36: OBJECT-ORIENTED ANALYSIS

CS3320::CH11 36

Operations--Activities & Actions

• Operations are performed in response to states or events:

• Activity: an operation that takes time to complete. – Continuous operations: display a picture– Sequential operations that terminate after an

interval of time: performing a computation, play a recorded message

Page 37: OBJECT-ORIENTED ANALYSIS

CS3320::CH11 37

Activities

– An activity continues until complete or interrupted by an event that causes transition to a another state

– e.g. ringing a telephone bell– Activities are associated with states

State1do: activity1do: activity2

Page 38: OBJECT-ORIENTED ANALYSIS

CS3320::CH11 38

Operations--Activities & Actions

• Action: is associated with an event• Instantaneous: duration is insignificant

compared to the resolution of the state diagram– e.g. when callee hangs-up disconnect phone

line

• Changing attribute values: – e.g. increment count when some event occurs.

Page 39: OBJECT-ORIENTED ANALYSIS

CS3320::CH11 39

Summary of Notation

State 1do: activity 1do: activity 2

State 2do: activity ...

Event [condition]/action

Page 40: OBJECT-ORIENTED ANALYSIS

CS3320::CH11 40

Page 41: OBJECT-ORIENTED ANALYSIS

CS3320::CH11 41

CASE Tools for OOA Phase

• Paradigm Plus• Software through Pictures• Rose