Slide 10B.1 Copyright © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. An Introduction to Object-Oriented Systems Analysis and Design with UML and the Unified Process McGraw-Hill, 2004 Stephen R. Schach
Slide 10B.2 Copyright © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. CHAPTER 10 — Unit B MORE ON UML
Slide 10B.3 Copyright © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Statecharts l Statechart with guards
Slide 10B.4 Copyright © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Statecharts (contd) l An event also causes transitions between states l Example: The receipt of a message
Slide 10B.5 Copyright © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Statecharts (contd) l 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
Slide 10B.6 Copyright © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Statecharts (contd) l Receipt of this message (event) causes the guard to be false l It also enables a transition to state Stopped at Floor –In this state, activity »Open the elevator doors is performed
Slide 10B.7 Copyright © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Statecharts (contd) l 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
Slide 10B.8 Copyright © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Statecharts (contd) l Equivalent statement with most general transition
Slide 10B.9 Copyright © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Statecharts (contd) l The transition label is –Elevator has arrived at floor [a message has been received] / Open the elevator doors l The guard –[a message has been received] is true when the event –Elevator has arrived at floor has occurred and the message has been sent l The action to be taken is –Open the elevator doors
Slide 10B.10 Copyright © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Statecharts (contd) l There are two places where an action can be performed in a statechart –When a state is entered »Activity –As part of a transition »Action
Slide 10B.11 Copyright © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Statecharts (contd) l An event can be specified in terms of words like “when” or “after” l Example: – When (cost > 1000) or after (2.5 seconds)
Slide 10B.12 Copyright © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Statecharts (contd) l Superstates combine related states
Slide 10B.13 Copyright © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Statecharts (contd) l States A, B, C, and D all have transitions to Next State l Combine them into superstate ABCD Combined –Now there is only one transition –The number of arrows is reduced from four to only one l States A, B, C, and D all still exist in their own right
Slide 10B.14 Copyright © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. l Example: Four states are unified into MSG Combined Statecharts (contd)
Slide 10B.15 Copyright © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Activity Diagrams l Activity diagrams show how various events are coordinated –Used when activities are carried on in parallel l Example: –One diner orders chicken, the other fish –The waiter writes down their order, and hands it to the chef –The meal is served only when both dishes have been prepared
Slide 10B.16 Copyright © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Activity Diagrams (contd) l Example:
Slide 10B.17 Copyright © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Activity Diagrams (contd) l 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 l A join has –Many 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
Slide 10B.18 Copyright © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Activity Diagrams (contd) l Example: A company that assembles computers as specified by the customer
Slide 10B.19 Copyright © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Activity Diagrams (contd) l The three departments involved –Assembly Department –Order Department –Accounts Receivable Department are each in their own swimlane
Slide 10B.20 Copyright © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Packages l A large information system is decomposed into relatively independent packages l UML notation for a package
Slide 10B.21 Copyright © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Packages (contd) l Example showing the contents of My Package
Slide 10B.22 Copyright © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Component Diagrams l A component diagram shows dependencies among software components, including –Source code –Compiled code –Executable load images
Slide 10B.23 Copyright © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Component Diagrams (contd) l Example: –Programmers write source code in an object-oriented language »C++ or Java –The source code is translated by a compiler into compiled code »(The binary code that is the only language a computer understands) –The compiled code for each module is combined with run- time routines to produce an executable load image (that is, a program)
Slide 10B.24 Copyright © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Component Diagrams (contd) l Example:
Slide 10B.25 Copyright © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Deployment Diagrams l A deployment diagram shows on which hardware component each software component is installed (or deployed) l It also shows the communication links between the hardware components
Slide 10B.26 Copyright © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Deployment Diagrams (contd) l Example:
Slide 10B.27 Copyright © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Review of UML Diagrams l 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
Slide 10B.28 Copyright © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Review of UML Diagrams l A statechart shows –States (specific values of attributes of objects) –Events that cause transitions between states (subject to guards), and –Actions taken by objects l An interaction diagram (sequence diagram or collaboration diagram) shows how objects interact as messages are passed between them l An activity diagram shows how events that occur at the same time are coordinated
Slide 10B.29 Copyright © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. UML and Iteration l Every UML diagram consists of a small required part plus any number of options –Not every feature of UML is applicable to every information system –To perform iteration and incrementation, features have to be added stepwise to diagrams l This is one of the many reasons why UML is so well suited to the Unified Process