slide 16b.51 © the mcgraw-hill companies, 2005 object-oriented and classical software engineering

29
Slide 16B.1 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering

Upload: nickolas-maxwell

Post on 12-Jan-2016

212 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Slide 16B.51 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering

Slide 16B.1

© The McGraw-Hill Companies, 2005

Object-Oriented and Classical Software

Engineering

Page 2: Slide 16B.51 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering

Slide 16B.2

© The McGraw-Hill Companies, 2005

CHAPTER 16 — Unit B

MORE ON UML

Page 3: Slide 16B.51 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering

Slide 16B.3

© The McGraw-Hill Companies, 2005

Continued from Unit 16B

Page 4: Slide 16B.51 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering

Slide 16B.4

© The McGraw-Hill Companies, 2005

16.7 Statecharts

Statechart with guards

Figure 16.16

Page 5: Slide 16B.51 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering

Slide 16B.5

© The McGraw-Hill Companies, 2005

Statecharts (contd)

An event also causes transitions between states Example: The receipt of a message

Figure 16.17

Page 6: Slide 16B.51 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering

Slide 16B.6

© The McGraw-Hill Companies, 2005

Statecharts (contd)

The elevator is in state Elevator Moving It performs operation

» Move up one floor

while guard [no message received yet] remains true, until it receives the message » Elevator has arrived at floor

Page 7: Slide 16B.51 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering

Slide 16B.7

© The McGraw-Hill Companies, 2005

Statecharts (contd)

Receipt of this message [event] causes the guard to be false

It also enables a transition to state Stopped at Floor In this state, activity

» Open the elevator doors

is performed

Page 8: Slide 16B.51 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering

Slide 16B.8

© The McGraw-Hill Companies, 2005

Statecharts (contd)

The most general form of a transition label is» event [guard] / action

If » event

has taken place and » [guard]

is true, the transition occurs, and, while it is occurring, » action

is performed

Page 9: Slide 16B.51 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering

Slide 16B.9

© The McGraw-Hill Companies, 2005

Statecharts (contd)

Equivalent statement with the most general transition

Figure 16.18

Page 10: Slide 16B.51 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering

Slide 16B.10

© The McGraw-Hill Companies, 2005

Statecharts (contd)

The transition label isElevator has arrived at floor [a message has been

received] / Open the elevator doors

The guard [a message has been received]

is true when the eventElevator has arrived at floor

has occurred and the message has been sent

The action to be taken is Open the elevator doors

Page 11: Slide 16B.51 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering

Slide 16B.11

© The McGraw-Hill Companies, 2005

Statecharts (contd)

There are two places where an action can be performed in a statechartWhen a state is entered

» Activity

As part of a transition» Action

Technical difference:An activity can take several seconds An action takes places essentially instantaneously

Page 12: Slide 16B.51 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering

Slide 16B.12

© The McGraw-Hill Companies, 2005

Statecharts (contd)

An event can be specified in terms of words like “when” or “after”

Example: when (cost > 1000) or after (2.5 seconds)

Page 13: Slide 16B.51 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering

Slide 16B.13

© The McGraw-Hill Companies, 2005

Statecharts (contd)

Superstates combine related states

Figure 16.19

Page 14: Slide 16B.51 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering

Slide 16B.14

© The McGraw-Hill Companies, 2005

Statecharts (contd)

States A, B, C, and D all have transitions to Next State

Combine them into superstate ABCD CombinedNow there is only one transitionThe number of arrows is reduced from four to only one

States A, B, C, and D all still exist in their own right

Page 15: Slide 16B.51 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering

Slide 16B.15

© The McGraw-Hill Companies, 2005

Example: Four states are unified into Osbert Combined

Statecharts (contd)

Figure 16.20

Page 16: Slide 16B.51 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering

Slide 16B.16

© The McGraw-Hill Companies, 2005

16.8 Activity Diagrams

Activity diagrams show how various events are coordinatedUsed when activities are carried on in parallel

Example: One diner orders chicken, the other fishThe waiter writes down their order, and hands it to the

chefThe meal is served only when both dishes have been

prepared

Page 17: Slide 16B.51 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering

Slide 16B.17

© The McGraw-Hill Companies, 2005

Activity Diagrams (contd)

Example:

Figure 16.21

Page 18: Slide 16B.51 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering

Slide 16B.18

© The McGraw-Hill Companies, 2005

Activity Diagrams (contd)

A fork has One incoming transition, and Many outgoing transitions, each of which starts an

activity to be executed in parallel with the other activities

A join hasMany incoming transitions, each of which lead from an

activity executed in parallel with the other activities, and One outgoing transition that is started when all the

parallel activities have been completed

Page 19: Slide 16B.51 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering

Slide 16B.19

© The McGraw-Hill Companies, 2005

Activity Diagrams (contd)

Example: A company

that assembles computers as specified by the customer

Figure 16.22

Page 20: Slide 16B.51 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering

Slide 16B.20

© The McGraw-Hill Companies, 2005

Activity Diagrams (contd)

The three departments involvedAssembly DepartmentOrder DepartmentAccounts Receivable Department

are each in their own swimlane

Page 21: Slide 16B.51 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering

Slide 16B.21

© The McGraw-Hill Companies, 2005

16.9 Packages

A large information system is decomposed into relatively independent packagesUML notation for a package

Figure 16.23

Page 22: Slide 16B.51 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering

Slide 16B.22

© The McGraw-Hill Companies, 2005

Packages (contd)

Example showing the contents of My Package

Figure 16.24

Page 23: Slide 16B.51 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering

Slide 16B.23

© The McGraw-Hill Companies, 2005

16.10 Component Diagrams

A component diagram shows dependencies among software components, including Source code (represented by a note)Compiled codeExecutable load images

Page 24: Slide 16B.51 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering

Slide 16B.24

© The McGraw-Hill Companies, 2005

Component Diagrams (contd)

Example:

Figure 16.25

Page 25: Slide 16B.51 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering

Slide 16B.25

© The McGraw-Hill Companies, 2005

16.11 Deployment Diagrams

A deployment diagram shows on which hardware component each software component is installed (or deployed)

It also shows the communication links between the hardware components

Page 26: Slide 16B.51 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering

Slide 16B.26

© The McGraw-Hill Companies, 2005

Deployment Diagrams (contd)

Example:

Figure 16.26

Page 27: Slide 16B.51 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering

Slide 16B.27

© The McGraw-Hill Companies, 2005

16.12 Review of UML Diagrams

Some diagrams that could be confused include:A use case models the interaction between actors and

the information system

A use-case diagram is a single diagram that incorporates a number of use cases

A class diagram is a model of the classes showing the static relationships between them» Including association and generalization

Page 28: Slide 16B.51 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering

Slide 16B.28

© The McGraw-Hill Companies, 2005

Review of UML Diagrams

A statechart shows States (specific values of attributes of objects),Events that cause transitions between states (subject to

guards), and Actions taken by objects

An interaction diagram (sequence diagram or collaboration diagram) shows how objects interact as messages are passed between them

An activity diagram shows how events that occur at the same time are coordinated

Page 29: Slide 16B.51 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering

Slide 16B.29

© The McGraw-Hill Companies, 2005

16.13 UML and Iteration

Every UML diagram consists of a small required part plus any number of optionsNot every feature of UML is applicable to every

information systemTo perform iteration and incrementation, features have

to be added stepwise to diagrams

This is one of the many reasons why UML is so well suited to the Unified Process