1. Trang chủ
  2. » Công Nghệ Thông Tin

Seventh Edition - Chương 12 doc

147 403 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 147
Dung lượng 11,35 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Slide 12.2012.5 Entity Class Modeling : The Elevator Problem Case Study  Represent them using a UML diagram cases and their scenarios  Possible danger: Often there are many scenarios,

Trang 2

Slide 12.2

CHAPTER 12

OBJECT-ORIENTED

ANALYSIS

Trang 3

Slide 12.3

Overview

Trang 4

Slide 12.4

Overview (contd)

Foundation case study

Foundation case study

Trang 5

Foundation case study

workflow

workflow

Trang 6

Slide 12.6

Object-Oriented Analysis

object-oriented paradigm

 There are over 60 equivalent techniques

 Today, the Unified Process is the only viable

alternative

 The classes are extracted

 The Unified Process assumes knowledge of class

extraction

Trang 7

Slide 12.7

12.1 The Analysis Workflow

 Obtain a deeper understanding of the requirements

 Describe them in a way that will result in a maintainable design and implementation

Trang 8

Slide 12.8

The Analysis Workflow (contd)

Trang 10

Investments Report Class

Mortgages Report Class

Trang 12

Slide 12.12

UML Notation for These Three Class Types

Figure 12.1

Trang 13

Slide 12.13

12.2 Extracting the Entity Classes

 Determine the entity classes and their attributes

 Determine the interrelationships and interactions between the entity classes

Present this information in the form of a class diagram

 Dynamic modeling

 Determine the operations performed by or to each entity class

Present this information in the form of a statechart

Trang 14

Slide 12.14

12.3 Object-Oriented Analysis: The Elevator Problem Case Study

A product is to be installed to control n elevators in a building with m floors The problem concerns the logic required to

move elevators between floors according to the following

constraints:

1 Each elevator has a set of m buttons, one for each floor These illuminate when pressed and cause the elevator to visit the corresponding floor The illumination is canceled when the corresponding floor is visited by the elevator

2 Each floor, except the first and the top floor, has two

buttons, one to request an up-elevator, one to request a

down-elevator These buttons illuminate when pressed The illumination is canceled when an elevator visits the floor, then moves in the desired direction

3 If an elevator has no requests, it remains at its current

floor with its doors closed

Trang 15

Slide 12.15

12.4 Functional Modeling: The Elevator Problem Case Study

 The product, and

 The actors (external users)

Trang 16

Slide 12.16

Use Cases

possible use cases

 Press an Elevator Button , and

 Press a Floor Button

Figure 12.2

Trang 17

Slide 12.17

Scenarios

overall functionality

comprehensive insight into the target product

being modeled

Trang 18

Slide 12.18

Normal Scenario: Elevator Problem

Trang 19

Slide 12.19

Exception Scenario: Elevator Problem

Trang 20

Slide 12.20

12.5 Entity Class Modeling : The Elevator Problem Case Study

 Represent them using a UML diagram

cases and their scenarios

 Possible danger: Often there are many scenarios, and hence

 Too many candidate classes

 CRC cards (if you have domain knowledge)

 Noun extraction

Trang 21

Slide 12.21

12.5.1 Noun Extraction

 Describe the software product in single paragraph

 Buttons in elevators and on the floors control the

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

Trang 22

Slide 12.22

Noun Extraction (contd)

 Identify the nouns in the informal strategy

 Buttons in elevators and on the floors control the

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

Trang 23

movement, illumination, request are abstract nouns —

exclude (they may become attributes)

Trang 24

Slide 12.24

First Iteration of Class Diagram

 Buttons do not communicate directly with elevators

We need an additional class: Elevator Controller Class

Figure 12.5

Trang 26

Slide 12.26

12.5.2 CRC Cards

 Name of Class

 Functionality (Responsibility)

 List of classes it invokes (Collaboration)

component)

Trang 29

Slide 12.29

Dynamic Modeling: Elevator Problem (contd)

transition diagram of Figures 11.15 through 11.17

events of the scenarios

Trang 31

Slide 12.31

CRC Cards

 1 Turn on elevator button

paradigm

 Responsibility-driven design has been ignored

 Information hiding has been ignored

Trang 32

Slide 12.32

CRC Cards (contd)

during execution (class characteristic)

Add class Elevator Doors Class

 Safety considerations

Trang 33

Slide 12.33

Second Iteration of the CRC Card

Figure 12.9

Trang 34

Slide 12.34

CRC Cards (contd)

 Use-case diagram (no change)

 Class diagram (see the next slide)

 Statecharts

 Scenarios (see the slide after the next slide)

Trang 35

Slide 12.35

Third Iteration of Class Diagram

Figure 12.10

Trang 36

Slide 12.36

Second Iteration of the Normal Scenario:

Figure 12.11

Trang 37

Slide 12.37

OOA: Elevator Problem (contd)

The object-oriented analysis is fine for now

analysis workflow during the object-oriented

design workflow

Trang 38

is modeled by its own boundary class

control class

Trang 39

Slide 12.39

12.9 The Initial Functional Model: MSG Foundation

Figure 12.12

Trang 40

Slide 12.40

Figure 12.13

Trang 41

Slide 12.41

Use Case Manage a Mortgage (contd)

Figure 12.14

Trang 42

Slide 12.42

Figure 12.15

Trang 43

Slide 12.43

Figure 12.16

Trang 44

Slide 12.44

Figure 12.17

Trang 45

Slide 12.45

12.10 The Initial Class Diagram: MSG Foundation

entity classes, determine their interrelationships, and find their attributes

the two-stage noun extraction method

Trang 46

Slide 12.46

Noun Extraction: MSG Foundation

single paragraph

 Weekly reports are to be printed showing how much money is available for mortgages In addition, lists of investments and mortgages must be printed on

demand.

Trang 47

Slide 12.47

Noun Extraction: MSG Foundation (contd)

 Weekly reports are to be printed showing how much money is available for mortgages In addition, lists of investments and mortgages must be printed on

demand.

investment

Trang 48

Slide 12.48

Noun Extraction: MSG Foundation (contd)

out to be a boundary class)

 money is an abstract noun

Mortgage Class and Investment Class

Trang 49

Slide 12.49

First Iteration of the Initial Class Diagram

Figure 12.18

Trang 50

Slide 12.50

Second Iteration of the Initial Class Diagram

are likely to be very similar

 Insertions, deletions, and modifications

 All members of both entity classes have to be printed on demand

Mortgage Class and Investment Class should be

subclasses of a superclass called Asset Class

Trang 51

Slide 12.51

Second Iteration of Initial Class Diagram (contd)

Figure 12.19

Trang 52

Slide 12.52

Back to the Requirements Workflow

and Manage an Investment

case, Manage an Asset

Trang 53

Slide 12.53

Eighth Iteration of the Use-Case Diagram

Figure 12.20

Trang 54

Slide 12.54

Initial Class Diagram: MSG Foundation (contd)

class diagram

 For the MSG Foundation case study, the result is

shown on the next slide

later be filled with the operations of that class

Trang 55

Slide 12.55

Second Iteration of Initial Class Diagram (contd)

Figure 12.21

Trang 56

Slide 12.56

Iteration and Incrementation

the possibility of having to decrement what has been developed to date

 A mistake may have been made, and backtracking is needed

 As a consequence of reorganizing the UML models, one or more artifacts may have become superfluous

Trang 57

Slide 12.57

12.11 The Initial Dynamic Model: MSG Foundation

the entity classes

operations performed by or to the software product

Trang 58

Slide 12.58

Initial Dynamic Model: MSG Foundation (contd)

Figure 12.22

Trang 59

Slide 12.59

Initial Dynamic Model: MSG Foundation (contd)

complete MSG Foundation information system

 The solid circle on the top left represents the initial state, the starting point of the statechart

 The white circle containing the small black circle on the top right represents the final state

 States other than the initial and final states are represented by rectangles with rounded corners

 The arrows represent possible transitions from state to state

Trang 60

Slide 12.60

Initial Dynamic Model: MSG Foundation (contd)

Loop, one of five events can occur

Trang 61

Slide 12.61

Initial Dynamic Model: MSG Foundation (contd)

 estimate funds for the week selected

 manage an asset selected

 update estimated annual operating expenses selected

 produce a report selected, and

 quit selected

Trang 62

Slide 12.62

Initial Dynamic Model: MSG Foundation (contd)

clicking on the menu

special software

Figure 12.23

Trang 63

Slide 12.63

Initial Dynamic Model: MSG Foundation (contd)

any computer

Figure 12.24

Trang 64

Slide 12.64

12.12 Revising the Entity Classes: MSG Foundation

diagram, and the initial dynamic model are

completed

 Checking them reveals a fault

Estimated Annual Operating Expenses with

operation Update the estimated annual operating expenses

 This operation has to be performed on the current value

of the estimated annual operating expense

Trang 65

Slide 12.65

Revising the Entity Classes: MSG Foundation (contd)

operating expenses to be found?

and its two subclasses

 Neither is appropriate for storing the estimated annual operating expenses

Trang 66

Slide 12.66

Revising the Entity Classes: MSG Foundation (contd)

basis is as an attribute of an instance of that class

or its subclasses

estimated annual operating expenses

MSG Application Class

Trang 68

Slide 12.68

Third Iteration of the Initial Class Diagram: MSG Foundation

Figure 12.26

Trang 69

Slide 12.69

12.13 Extracting the Boundary Classes: MSG Foundation

 Each input screen, output screen, and printed report is generally modeled by a boundary class

Foundation use cases

 Estimate Funds Available for Week

 Manage an Asset

 Update Estimated Annual Operating Expenses

 Produce a Report

User Interface Class

Trang 70

Slide 12.70

Extracting Boundary Classes: MSG Foundation (contd)

 The estimated funds for the week report

 The listing of all mortgages

 The listing of all investments

boundary class

Estimated Funds Report Class

Mortgages Report Class

Investments Report Class

Trang 71

Slide 12.71

Extracting Boundary Classes: MSG (contd)

Figure 12.27

Trang 72

Slide 12.72

Initial Boundary Classes: MSG Foundation (contd)

 The purchases report

 The sales report

 The future trends report

 Each report therefore has to be modeled by a separate boundary class

Trang 73

Slide 12.73

12.14 Extracting the Control Classes: MSG Foundation

class

 Estimate the funds available for the week

Figure 12.28

Trang 74

Slide 12.74

Class Extraction (contd)

Trang 75

Slide 12.75

12.15 Use-Case Realization: The MSG Foundation Case Study

called use-case realization

Trang 76

Slide 12.76

Use-Case Realization (contd)

 Understand (“Harvey slowly began to realize that he was in the wrong classroom”);

 Receive (“Ingrid will realize a profit of $45,000 on the stock transaction”); and

 Accomplish (“Janet hopes to realize her dream of

starting a computer company”)

“realize” is used in this last sense

Trang 77

Slide 12.77

Use-Case Realization (contd)

is depicted using an interaction diagram

 Either a sequence diagram or collaboration diagram

Week

 The use case

 The description of the use case

Trang 78

Slide 12.78

12.15.1 Estimate Funds Available for Week Use Case

Figure 12.29

Trang 79

Slide 12.79

Estimate Funds Available for Week Use Case (contd)

of use case

Trang 80

Slide 12.80

Estimate Funds Available for Week Use Case (contd)

case)

Figure 12.31

Trang 81

Slide 12.81

© The McGraw-Hill Companies, 2007

Estimate Funds Available for Week Use Case (contd)

User Interface Class

 This class models the user interface

Estimate Funds for Week Class

 This control class models the computation of the estimate of the funds that are available to fund mortgages during that week

Trang 82

Slide 12.82

Estimate Funds Available for Week Use Case (contd)

Figure 12.32

Trang 83

Slide 12.83

Estimate Funds Available for Week Use Case (contd)

classes

 Example: A specific mortgage cannot be represented

by Mortgage Class but rather by an object, a specific instance of Mortgage Class

Trang 84

Slide 12.84

Estimate Funds Available for Week Use Case (contd)

and their relationships

 It does not show the objects nor the sequence of

messages as they are sent from object to object

Trang 85

Slide 12.85

Estimate Funds Available for Week Use Case (contd)

scenario of the use case)

Figure 12.33

Trang 86

Slide 12.86

Estimate Funds Available for Week Use Case (contd)

well as the messages, numbered in the order in which they are sent in the specific scenario

Trang 87

 1: Request estimate of funds available for week

from MSG Staff Member to : User Interface Class, an instance of User Interface Class

Trang 88

Slide 12.88

Estimate Funds Available for Week Use Case (contd)

This request is passed on to : Estimate Funds for

Week Class, an instance of the control class that

actually performs the calculation

 This is modeled by message

 2: Transfer request

determined by : Estimate Funds for Week Class

Trang 89

Slide 12.89

Estimate Funds Available for Week Use Case (contd)

 In Step 1 of the scenario, the estimated annual return

on investments is summed for each investment and the result divided by 52

 This extraction of the estimated weekly return is

modeled by message

 3: Request estimated return on investments for week

from : Estimate Funds for Week Class

to : Investment Class followed by message

 4: Return estimated weekly return on investments

in the other direction

Trang 90

Slide 12.90

Estimate Funds Available for Week Use Case (contd)

 In Step 2 of the scenario, the weekly operating

expenses are estimated by taking the estimated annual operating expenses and dividing by 52

 This extraction of the weekly expenses is modeled by message

 5: Request estimated operating expenses for week

from : Estimate Funds for Week Class to : MSG Application Class followed by message

 6: Return estimated operating expenses for week

in the other direction

Trang 91

 the estimated grants for the week, and

 the estimated payments for the week

 This is modeled by message

 7: Request estimated grants and payments for week

from : Estimate Funds for Week Class to : Mortgage Class, and by message

 8: Return estimated grants and payments for week

in the other direction

Trang 92

 This is modeled by message

 9: Compute estimated amount available for week

 This is a self call

: Estimate Funds for Week Class tells itself to perform

the calculation

The result of the computation is stored in : MSG

Application Class by message

 10: Transfer estimated amount available for week

Trang 93

Slide 12.93

Estimate Funds Available for Week Use Case (contd)

 The result is printed in Step 7 of the scenario

 This is modeled by message

 11: Print estimated amount available

from : MSG Application Class to : Estimated Funds Report Class

Trang 94

 This is modeled by messages

 12: Send successful completion message

 13: Send successful completion message

 14: Transfer successful completion message, and

 15: Display successful completion message

Trang 95

Slide 12.95

Estimate Funds Available for Week Use Case (contd)

without understanding it

collaboration diagram is needed, the flow of events

Trang 96

Slide 12.96

Estimate Funds Available for Week Use Case (contd)

the realization of the scenario of the use case

Figure 12.34

Trang 98

Slide 12.98

Interaction Diagrams

shows the flow of messages and their order

 When the developers are concentrating on the classes,

a collaboration diagram is more useful than the

equivalent sequence diagram

Trang 99

Slide 12.99

Estimate Funds Available for Week Use Case (contd)

random collection of UML artifacts

artifacts derived from that use case

Trang 100

Slide 12.100

Estimate Funds Available for Week Use Case (contd)

Available for Week

 All possible sets of interactions

Between the actor MSG Staff Member (external to the

software product) and the MSG Foundation software product itself

 That relate to the action of estimating funds available for the week

Ngày đăng: 01/08/2014, 14:20

TỪ KHÓA LIÊN QUAN