38
Slide 12C.1 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering Sixth Edition, WCB/McGraw-Hill, 2005

Slide 12C.50 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering Sixth Edition, WCB/McGraw-Hill, 2005

Embed Size (px)

Citation preview

Page 1: Slide 12C.50 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering Sixth Edition, WCB/McGraw-Hill, 2005

Slide 12C.1

© The McGraw-Hill Companies, 2005

Object-Oriented and Classical Software

Engineering

Sixth Edition, WCB/McGraw-Hill, 2005

Page 2: Slide 12C.50 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering Sixth Edition, WCB/McGraw-Hill, 2005

Slide 12C.2

© The McGraw-Hill Companies, 2005

CHAPTER 12 — Unit C

OBJECT-ORIENTED ANALYSIS

Page 3: Slide 12C.50 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering Sixth Edition, WCB/McGraw-Hill, 2005

Slide 12C.3

© The McGraw-Hill Companies, 2005

Continued from Unit 12B

Page 4: Slide 12C.50 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering Sixth Edition, WCB/McGraw-Hill, 2005

Slide 12C.4

© The McGraw-Hill Companies, 2005

12.10 The Initial Class Diagram: The Osbert Oglesby Case Study

The aim of entity modeling step is to extract the entity classes, determine their interrelationships, and find their attributes

Usually, the best way to begin this step is to use the two-stage noun extraction method

Page 5: Slide 12C.50 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering Sixth Edition, WCB/McGraw-Hill, 2005

Slide 12C.5

© The McGraw-Hill Companies, 2005

Noun Extraction: Osbert Oglesby Case Study

Stage 1: Describe the software product in one paragraph:Reports are to be generated in order to improve the

effectiveness of the decision-making process for buying works of art. The reports contain buying and selling information about paintings, which are classified as masterpieces, masterworks, and other paintings

Page 6: Slide 12C.50 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering Sixth Edition, WCB/McGraw-Hill, 2005

Slide 12C.6

© The McGraw-Hill Companies, 2005

Noun Extraction: Osbert Oglesby (contd)

Stage 2: Identify the nouns in this paragraphReports are to be generated in order to improve the

effectiveness of the decision-making process for buying works of art. The reports contain buying and selling information about paintings, which are classified as masterpieces, masterworks, and other paintings

Page 7: Slide 12C.50 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering Sixth Edition, WCB/McGraw-Hill, 2005

Slide 12C.7

© The McGraw-Hill Companies, 2005

Noun Extraction: Osbert Oglesby (contd)

The nouns are report, effectiveness, process, buying,

work of art, selling, information, painting, masterpiece, and masterwork

effectiveness, process and information are abstract nouns and are therefore unlikely to be entity classes

Nouns buying and selling are derived from the verbs “buy” and “sell”They will probably be operations of some class

Page 8: Slide 12C.50 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering Sixth Edition, WCB/McGraw-Hill, 2005

Slide 12C.8

© The McGraw-Hill Companies, 2005

Noun Extraction: Osbert Oglesby (contd)

Noun report is much more likely to be a boundary class than an entity class

Noun work of art is just a synonym for painting

Page 9: Slide 12C.50 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering Sixth Edition, WCB/McGraw-Hill, 2005

Slide 12C.9

© The McGraw-Hill Companies, 2005

First Iteration of the Initial Class Diagram

This leaves four candidate entity classes: Painting Class, Masterpiece Class, Masterwork

Class, and Other Painting Class

Figure 12.17

Page 10: Slide 12C.50 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering Sixth Edition, WCB/McGraw-Hill, 2005

Slide 12C.10

© The McGraw-Hill Companies, 2005

Second Iteration of the Initial Class Diagram

Consider the interrelationships between the entity classes

A masterpiece is a specific type of painting, and so is a masterwork and an “other painting” Painting Class is therefore the base classMasterpiece Class, Masterwork Class, and Other

Painting Class are subclasses of that base class

Page 11: Slide 12C.50 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering Sixth Edition, WCB/McGraw-Hill, 2005

Slide 12C.11

© The McGraw-Hill Companies, 2005

Second Iteration of Initial Class Diagram (contd)

Figure 12.18

Page 12: Slide 12C.50 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering Sixth Edition, WCB/McGraw-Hill, 2005

Slide 12C.12

© The McGraw-Hill Companies, 2005

The class diagram does not reflect aspects of the pricing algorithm

When dealing with a masterwork “The software product first computes the maximum

purchase price as if it were a masterpiece by the same artist”

Third Iteration of the Initial Class Diagram

Page 13: Slide 12C.50 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering Sixth Edition, WCB/McGraw-Hill, 2005

Slide 12C.13

© The McGraw-Hill Companies, 2005

That is, a masterwork has to have all the attributes of a masterpiece (so that its maximum purchase price can be computed as if it were a masterpiece) and, in addition, it may have attributes of its ownThis is modeled in the next slide

Third Iteration of the Initial Class Diagram (contd)

Page 14: Slide 12C.50 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering Sixth Edition, WCB/McGraw-Hill, 2005

Slide 12C.14

© The McGraw-Hill Companies, 2005

Third Iteration of the Initial Class Diagram (contd)

Figure 12.19

Page 15: Slide 12C.50 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering Sixth Edition, WCB/McGraw-Hill, 2005

Slide 12C.15

© The McGraw-Hill Companies, 2005

Fourth Iteration of the Initial Class Diagram

Another aspect of the pricing algorithm that is not reflected in the current class diagram is “The software product computes the coefficient of

similarity between each painting (by the same artist) for which there is an auction record and the painting under consideration for purchase”

Page 16: Slide 12C.50 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering Sixth Edition, WCB/McGraw-Hill, 2005

Slide 12C.16

© The McGraw-Hill Companies, 2005

Fourth Iteration of Initial Class Diagram (contd)

Auctioned Painting Class is needed to make these comparisonsAn auctioned painting must be a subclass of Painting

ClassBut a painting previously been sold at an auction

somewhere in the world has nothing to do with paintings currently on display for sale in Osbert’s gallery

Page 17: Slide 12C.50 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering Sixth Edition, WCB/McGraw-Hill, 2005

Slide 12C.17

© The McGraw-Hill Companies, 2005

Fourth Iteration of Initial Class Diagram (contd)

Figure 12.20

Page 18: Slide 12C.50 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering Sixth Edition, WCB/McGraw-Hill, 2005

Slide 12C.18

© The McGraw-Hill Companies, 2005

Fourth Iteration of Initial Class Diagram (contd)

An instance of Painting Class is either A painting that Osbert has bought (an instance of

Gallery Painting Class), or A painting sold at some auction (an instance of

Auctioned Painting Class)

Page 19: Slide 12C.50 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering Sixth Edition, WCB/McGraw-Hill, 2005

Slide 12C.19

© The McGraw-Hill Companies, 2005

Fifth Iteration of the Initial Class Diagram

A third aspect of the maximum price algorithm that has not yet been modeled is fashionability “The software product computes the maximum

purchase price from the formula F A , where F is a constant for that artist (fashionability coefficient) …”

Fashionability Class is needed A painting of Other Painting Class can then use the

instance of Fashionability Class for that artist to compute the maximum price that Osbert should offer to pay

Page 20: Slide 12C.50 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering Sixth Edition, WCB/McGraw-Hill, 2005

Slide 12C.20

© The McGraw-Hill Companies, 2005

Fifth Iteration of the Initial Class Diagram (contd)

Figure 12.21

Page 21: Slide 12C.50 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering Sixth Edition, WCB/McGraw-Hill, 2005

Slide 12C.21

© The McGraw-Hill Companies, 2005

Initial Class Diagram:Osbert Oglesby (contd)

Why was the first iteration of the class diagram so inadequate? The Osbert Oglesby case study appears to be a

straightforward data-processing applicationThe one-paragraph description correctly did not

incorporate the pricing algorithm

Unfortunately, the algorithmic details turned out to be critical to the class diagram

Page 22: Slide 12C.50 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering Sixth Edition, WCB/McGraw-Hill, 2005

Slide 12C.22

© The McGraw-Hill Companies, 2005

Initial Class Diagram:Osbert Oglesby (contd)

The first iteration of the class diagram was no goodHowever, repeated iteration and incrementation led to a

reasonable class diagram

This demonstrates the power of the iterative and incremental approach

Page 23: Slide 12C.50 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering Sixth Edition, WCB/McGraw-Hill, 2005

Slide 12C.23

© The McGraw-Hill Companies, 2005

Initial Class Diagram:Osbert Oglesby (contd)

Finally, we add the attributes of each class to the class diagramFor the Osbert Oglesby case study, the result is shown

on the next slide

The empty rectangle at the bottom of each box will later be filled with the operations of that class

Page 24: Slide 12C.50 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering Sixth Edition, WCB/McGraw-Hill, 2005

Slide 12C.24

© The McGraw-Hill Companies, 2005

Fifth Iteration of the Initial Class Diagram (contd)

Figure 12.22

Page 25: Slide 12C.50 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering Sixth Edition, WCB/McGraw-Hill, 2005

Slide 12C.25

© The McGraw-Hill Companies, 2005

Fifth Iteration of the Initial Class Diagram (contd)

Osbert Oglesby Application Class will contain the operation that starts execution of the whole software product

Page 26: Slide 12C.50 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering Sixth Edition, WCB/McGraw-Hill, 2005

Slide 12C.26

© The McGraw-Hill Companies, 2005

Fifth Iteration of the Initial Class Diagram (contd)

The next slide shows the fifth iteration of the initial class diagram, without the attributes, but explicitly reflecting the stereotypesAll eight classes in that figure are entity classes

This is also a class diagramA class diagram depicts classes and their

interrelationships; attributes and operations are optional

Page 27: Slide 12C.50 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering Sixth Edition, WCB/McGraw-Hill, 2005

Slide 12C.27

© The McGraw-Hill Companies, 2005

Fifth Iteration of the Initial Class Diagram (contd)

Figure 12.23

Page 28: Slide 12C.50 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering Sixth Edition, WCB/McGraw-Hill, 2005

Slide 12C.28

© The McGraw-Hill Companies, 2005

12.11 The Initial Dynamic Model: The Osbert Oglesby Case Study

Dynamic modeling is the third step in extracting the entity classes

A statechart is constructed that reflects all the operations performed by or to the software product (rather than by or to each class; justification is given later)

The operations are determined from the scenarios

Page 29: Slide 12C.50 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering Sixth Edition, WCB/McGraw-Hill, 2005

Slide 12C.29

© The McGraw-Hill Companies, 2005

Initial Dynamic Model: Osbert Oglesby (contd)

Initial statechart

Figure 12.24

Page 30: Slide 12C.50 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering Sixth Edition, WCB/McGraw-Hill, 2005

Slide 12C.30

© The McGraw-Hill Companies, 2005

Initial Dynamic Model: Osbert Oglesby (contd)

The solid circle (top left) represents the initial state

The white circle with the small black circle inside (top right) represents the final state

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

The arrows represent transitions from state to state

Page 31: Slide 12C.50 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering Sixth Edition, WCB/McGraw-Hill, 2005

Slide 12C.31

© The McGraw-Hill Companies, 2005

Initial Dynamic Model: Osbert Oglesby (contd)

In state Osbert Oglesby Event Loop, one of five events can occur:buy painting selectedsell painting selectedprint report selectedupdate fashionability selectedquit selected

Page 32: Slide 12C.50 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering Sixth Edition, WCB/McGraw-Hill, 2005

Slide 12C.32

© The McGraw-Hill Companies, 2005Figure 12.25

Initial Main Menu: Osbert Oglesby

Graphical user interface (GUI) “Point and click”

Page 33: Slide 12C.50 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering Sixth Edition, WCB/McGraw-Hill, 2005

Slide 12C.33

© The McGraw-Hill Companies, 2005

Dynamic Modeling (contd)

In the object-oriented paradigm, there is a dynamic model for each class, rather than for the system as a whole, as in this case study+ In this case study , objects in this software product

never move from one class to another class

Accordingly, a dynamic model for the software product as a whole is appropriate

Page 34: Slide 12C.50 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering Sixth Edition, WCB/McGraw-Hill, 2005

Slide 12C.34

© The McGraw-Hill Companies, 2005

12.12 Extracting the Boundary Classes: The Osbert Oglesby Case Study

It is usually easy to extract boundary classesEach input screen, output screen, and printed report is

generally modeled by a boundary class

One screen should be adequate for all four Osbert Oglesby use cases

Thus there is one initial boundary classUser Interface Class

Page 35: Slide 12C.50 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering Sixth Edition, WCB/McGraw-Hill, 2005

Slide 12C.35

© The McGraw-Hill Companies, 2005

Initial Main Menu: Osbert Oglesby (contd)

A GUI needs special software However, a textual interface runs on all computers

Figure 12.26

Page 36: Slide 12C.50 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering Sixth Edition, WCB/McGraw-Hill, 2005

Slide 12C.36

© The McGraw-Hill Companies, 2005

Initial Boundary Classes: Osbert Oglesby (contd)

There are three reports: The purchases reportThe sales reportThe future trends report

The content of each report is different Each report therefore has to be modeled by a separate

boundary class

Page 37: Slide 12C.50 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering Sixth Edition, WCB/McGraw-Hill, 2005

Slide 12C.37

© The McGraw-Hill Companies, 2005

Initial Boundary Classes: Osbert Oglesby (contd)

There are therefore four initial boundary classes

Figure 12.27

Page 38: Slide 12C.50 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering Sixth Edition, WCB/McGraw-Hill, 2005

Slide 12C.38

© The McGraw-Hill Companies, 2005

Continued in Unit 12D