UML 2 Toolkit, Penker Has Also Collaborated with Hans- Erik Eriksson on Business Modeling with UML: Business Practices at Work
Total Page:16
File Type:pdf, Size:1020Kb
UML™ 2 Toolkit Hans-Erik Eriksson Magnus Penker Brian Lyons David Fado UML™ 2 Toolkit UML™ 2 Toolkit Hans-Erik Eriksson Magnus Penker Brian Lyons David Fado Publisher: Joe Wikert Executive Editor: Bob Elliott Development Editor: Kevin Kent Editorial Manager: Kathryn Malm Production Editor: Pamela Hanley Permissions Editors: Carmen Krikorian, Laura Moss Media Development Specialist: Travis Silvers Text Design & Composition: Wiley Composition Services Copyright 2004 by Hans-Erik Eriksson, Magnus Penker, Brian Lyons, and David Fado. All rights reserved. Published by Wiley Publishing, Inc., Indianapolis, Indiana Published simultaneously in Canada No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning, or otherwise, except as permitted under Section 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, Inc., 222 Rose- wood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8700. Requests to the Pub- lisher for permission should be addressed to the Legal Department, Wiley Publishing, Inc., 10475 Crosspoint Blvd., Indianapolis, IN 46256, (317) 572-3447, fax (317) 572-4447, E-mail: [email protected]. Limit of Liability/Disclaimer of Warranty: While the publisher and author have used their best efforts in preparing this book, they make no representations or warranties with respect to the accuracy or completeness of the contents of this book and specifically disclaim any implied warranties of merchantability or fitness for a particular purpose. No warranty may be created or extended by sales representatives or written sales materials. The advice and strategies contained herein may not be suitable for your situation. You should consult with a professional where appropriate. Neither the publisher nor author shall be liable for any loss of profit or any other commercial damages, including but not limited to special, inci- dental, consequential, or other damages. For general information on our other products and services please contact our Customer Care Department within the United States at (800) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002. Trademarks: Wiley and the Wiley Publishing logo are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates. UML is a trademark of Object Management Group, Inc. All other trademarks are the property of their respective owners. Wiley Pub- lishing, Inc., is not associated with any product or vendor mentioned in this book. Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books. Library of Congress Cataloging-in-Publication Data: Library of Congress Control Number: 2003015155 ISBN: 0-471-46361-2 Printed in the United States of America 10 9 8 7 6 5 4 3 2 1 Contents OMG Press Books in Print xiv About the OMG xvii 2003 OMG Press Advisory Board xix Preface for the Second Edition xxi About the Authors xxv Acknowledgments xxvii Chapter 1 What Is UML? 1 The Purpose of Modeling 2 Software Development, Methods, and Models 4 The Method Wars 6 Acceptance of UML 8 The Object Management Group 9 Unified Modeling Language Elements 9 Methods and Modeling Languages 10 Object-Oriented Software Development 11 Concepts of Object Orientation 12 Business Engineering 13 Disciplines of System Development 13 Requirements 14 Analysis 14 Design 14 Implementation 15 Test 15 Relevant Changes in UML 2 15 Summary 17 v vi Contents Chapter 2 An Overview of UML 19 Views 21 Use-Case View 22 Logical View 23 Implementation View 23 Process View 23 Deployment View 24 Diagrams 24 Use-Case Diagram 24 Class Diagram 25 Object Diagram 25 State Machines 26 Activity Diagram 28 Interaction Diagrams 29 Sequence Diagram 29 Communication Diagram 30 Interaction Overview Diagram 31 Component Diagram 32 Deployment Diagram 32 Composite Structure Diagram 33 Model Elements 34 General Mechanisms 36 Adornments 36 Comments 37 Specifications 37 Extending UML 38 Stereotypes 39 Tagged Values 40 Constraints 40 Model Driven Architecture with UML 41 Software Development Process and UML 43 Tools 45 Drawing Support 47 Model Repository 47 Navigation 48 Multiuser Support 49 Code Generation 49 Reverse Engineering 50 Integration 50 Interchange of Models 51 Tool Options 52 Relevant Changes in UML 2 53 Summary 55 Chapter 3 Use-Case Modeling 57 Basics of Use Cases 58 Use-Case Diagram 60 System 61 Contents vii Actors 62 Finding Actors 63 Actors in UML 64 Relationships between Actors 65 Use Cases 66 Finding Use Cases 67 Use Cases in UML 67 Relationships between Use Cases 68 Generalization Relationship 68 Extend Relationship 69 Include Relationship 70 Organizing Use Cases 71 Describing Use Cases 74 Assessing Use Cases 76 Testing Use Cases 77 Use Cases and Requirements Management 78 Realizing Use Cases 79 Relevant Changes in UML 2 83 Summary 84 Chapter 4 Classes, Objects, and Their Relationships 87 Classes and Objects 87 Class Diagram 90 Finding Classes 90 Name Compartment 91 Attributes Compartment 92 Java Implementation 95 Operations Compartment 95 Using Primitive Types 99 Relationships 99 Associations 100 Normal Association 100 Object Diagram 103 Recursive Association 103 Java Implementation 104 Roles in an Association 106 Qualified Association 106 Xor Constraint 108 Ordered Association 109 Association Class 109 Ternary Association 110 Aggregation 111 Aggregate 112 Shared Aggregation 112 Composition Aggregation 113 viii Contents Generalization 115 Basic Generalization 116 Advanced Generalization 123 Generalization Set 123 Powertype 125 Dependencies and Abstractions 126 Constraints, Expressions, and Derivations 128 Interfaces and Ports 131 Java Implementation 133 Ports 134 Packages 135 Templates 140 Relevant Changes in UML 2 141 Summary 142 Chapter 5 Dynamic Modeling 145 State Machines 147 States and Transitions 147 Event-Signature 151 Guard-Condition 152 Action-Expression 153 Send-Clause 154 Events 155 Java Implementation 157 Sending Messages Between State Machines 159 Substates 160 Entry, Exit, and Terminate Indicators 161 History Indicator 162 Activity Diagrams 163 Actions and Edges 163 Activity Partitions 166 Objects 168 Signals 169 Pins 170 Business Modeling with Activity Diagrams 171 Interaction Diagrams 173 Sequence Diagrams 174 Generic and Instance Form 174 Concurrent Objects 176 Combined Fragments 176 Interaction Occurrences 179 Creating and Destroying Objects 179 Recursion 180 Interaction Overviews 180 Communication Diagrams 182 Message Labels 183 Using Communication Diagrams 185 Relevant Changes in UML 2 188 Summary 188 Contents ix Chapter 6 Advanced Dynamic Modeling Illustrated by Real-Time Systems 191 What Is a Real-Time System? 191 Attributes of a Real-Time System 192 Types of Real-Time Systems 192 Concepts in UML for Real-Time Systems 193 Active Classes and Active Objects 193 Active Class Implementation 194 Active Object Interactions 194 Communication 195 Events and Triggers 197 Signals 198 Messages 199 Synchronization and Concurrency 200 Synchronization Issues 201 Synchronization Mechanisms 202 Fault Tolerance 203 Implementation in Java 204 UML Time Elements 205 Real-Time Modeling in UML Diagrams 206 Activity Diagrams 207 The Token Flow Model in Activity Diagrams 207 Chocolate Factory: Streaming Input and Output Example 208 Processing Applications: Expansion Regions and Structured Activities 210 Investment Simulation: Interruptible Regions and Storage 213 House Alarm: Static Structure for Dynamic Messages 216 Static Diagrams 216 Detailed Activity Diagram Showing Message Handling 221 Interaction Diagrams 223 Communication Diagrams 223 Basic Sequence Diagram 224 Advanced Sequence Diagrams with Combined Fragments 227 Timing Diagrams 230 Behavioral State Machines 231 Handling Active Classes and Objects 231 State Machine Regions and Concurrency 232 Handling Triggers on Events in Composite States 234 Transitions and Synchronization 235 Complex State Machines and Run-to-Completion Semantics 236 State Machine Redefinition and Reuse 238 Protocol State Machines 239 Advanced Modeling, Design, and Optimization 241 Design Overview 242 Modeling Processes and Threads with Objects 242 Designing Active Classes 243 x Contents Design and the Implementation Environment 244 Approaches to Showing Behavioral Diagrams 244 Performance Optimization 246 Design Optimization 247 Optimization and the Operating System 247 Relevant Changes in UML 2 248 Summary 249 Chapter 7 Representing Architecture 251 Logical Architecture 254 Logical Architecture Structure 254 Components 255 Collaborations 257 Composite Structure Diagrams 258 Patterns in Architecture 258 The Proxy Pattern 261 Modeling Patterns in UML 263 Showing Patterns in Diagrams 266 Patterns and Use Cases 269 Physical Architecture 270 Hardware 270 Software 271 Component Diagram 272 Deployment Diagram 273 Nodes 274 Communication Paths 275 Deployed Artifacts 275 Allocating Artifacts to Nodes 276 Relevant Changes in UML 2 277 Summary 278 Chapter 8 Extending UML 281 Standard Extensions Overview 282 Tagged Values and Properties 283 Standard Tag Value Examples 284 Tag Value from a Profile 285 Defining Your Own Tagged Values 286 Stereotypes 287 Creating a Stereotype 287 Examples of UML Stereotypes 289 Metainformation 289 Dependency Stereotypes 289 Customization with Components 290 Stereotypes Applied to