Xem mẫu

  1. UML™ 2 Toolkit Hans-Erik Eriksson Magnus Penker Brian Lyons David Fado
  2. UML™ 2 Toolkit
  3. UML™ 2 Toolkit Hans-Erik Eriksson Magnus Penker Brian Lyons David Fado
  4. 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: permcoordinator@wiley.com. 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
  5. 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
  6. 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
  7. 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
  8. 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
  9. 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
  10. 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 Deployment Artifacts 291 Utility 292 Use Case Stereotypes 293 Signal 293
  11. Contents xi Control, Boundary, and Entity 295 Stereotypes for Creation and Destruction 298 Retired Standard Stereotypes 299 Defining Your Own Stereotypes 299 Constraints 301 Examples of UML Constraints 302 Constraints for Associations 302 Constraints for Association Roles and Properties 303 Defining Your Own Constraints 304 A Language for Expressing Constraints 306 OCL Metamodel 306 Basic Structure of OCL Expressions 308 Invariants, Preconditions, and Postconditions 308 Language Architecture and Kernel Overview 310 High-Level Language Constructs 310 Reviewing the UML Kernel 312 The Profile Package 318 Architecture Overview Summary and Observations 321 Relevant Changes in UML 2 321 Summary 322 Chapter 9 Model Driven Architecture 325 MDA Evolution and Goals 326 Background and General Goals 326 Model Levels 329 Model Compilers 332 Mapping the Many Elements of MDA 333 From the Business Model to PIM and PSM 335 The High-Level Review 335 Defining Functionality with No Platform 339 Platform-Specific Models 340 Information Management Solution 342 Tips for Modeling in the MDA World 343 Modeling for Business and Functional Analysis 343 Modeling for the Software Architect 344 Modeling for the Developer 345 High-Level Assessment of MDA Opportunities 347 Opportunities 347 A Necessary Evolutionary Step for Increased Coordination 347 Cost-Aware MDA 348 Warnings 350 Too Much Modeling Overhead and Complexity 350 Lack of Universality in Tool Implementation 351 Untested Behavioral Modeling 351 Misuse of MDA 351 Summary 352
  12. xii Contents Chapter 10 A Process for Using UML 353 Defining and Understanding Software-Engineering Processes 354 Process Context 355 Process User 356 Process Steps 356 Problem Formulation 357 Solution Design 358 Implementation Design 358 Process Evaluation 358 The Basis for a UML Process 359 Use-Case-Driven Systems 360 Architecture-Centric Approach 360 Iterative Approach 361 Incremental Approach 363 A Traditional Object-Oriented Method 365 Requirements 366 Analysis 367 Design 368 Implementation 370 Test 371 The Unified Process 373 The Life Cycle 374 Inception 375 Elaboration 376 Construction 376 Transition 376 Comparing the Unified Process to a Traditional Process 377 Process Tools 378 Model Quality 380 What Is a Good Model? 381 Can You Communicate the Model? 381 Does the Model Fit Its Purpose? 382 Does the Model Capture the Essentials? 382 Naming Conventions 382 Model Coordination 383 Model Complexity 383 Summary 383 Chapter 11 Case Study 387 Requirements 389 Developing a Vision 390 Modeling Use Cases 391 Establishing the Domain Model 394 Analysis 396 Performing Use-Case Analysis 397 Not UML? How Can That Be? 401
  13. Contents xiii Design 403 Designing the Architecture 404 System Structure 404 Architectural Mechanisms 406 Design Patterns 407 Design Policies 409 Performing Detailed Design 410 business Package 411 presentation Package 411 Use-Case Design 412 Designing the User Interface 415 Implementation 415 Test and Deployment 418 Summary 420 Exercises 420 Requirements and Analysis Exercises 420 Design and Construction Exercises 421 Appendix A Visual Glossary 423 Appendix B Glossary 461 Appendix C References 475 Appendix D What’s on the CD-ROM? 479 Index 485 End-User License Agreement 513 GNU General Public License 515
  14. OMG Press Books in Print For complete information about current and upcoming titles, go to www .wiley.com/compbooks/omg/. Building Business Objects by Peter Eeles and Oliver Sims, ISBN: ■■ 0-471-19176-0. Business Component Factory: A Comprehensive Overview of ■■ Component-Based Development for the Enterprise by Peter Herzum and Oliver Sims, ISBN: 0-471-32760-3. Business Modeling with UML: Business Patterns at Work by Hans-Erik ■■ Eriksson and Magnus Penker, ISBN: 0-471-29551-5. Common Warehouse Metamodel Developer’s Guide by John Poole, Dan ■■ Chang, Douglas Tolbert, and David Mellor, ISBN: 0-471-20243-6. CORBA 3 Fundamentals and Programming, 2nd Edition by Jon Siegel, ■■ ISBN: 0-471-29518-3. CORBA Design Patterns by Thomas J. Mowbray and Raphael C. ■■ Malveau, ISBN: 0-471-15882-8. Enterprise Application Integration with CORBA: Component and Web- ■■ Based Solutions by Ron Zahavi, ISBN: 0-471-32720-4. Enterprise Integration: An Architecture for Enterprise Application and ■■ Systems Integration by Fred A. Cummins, ISBN: 0-471-40010-6. Enterprise Java with UML, Second Edition by C.T. Arrington and Syed ■■ H. Rayhan, ISBN: 0-471-26778-3. Enterprise Security with EJB and CORBA by Bret Hartman, Donald J. ■■ Flinn, and Konstantin Beznosov, ISBN: 0-471-15076-2. xiv
  15. OMG Press Books in Print xv The Essential CORBA: Systems Integration Using Distributed Objects ■■ by Thomas J. Mowbray and Ron Zahavi, ISBN: 0-471-10611-9. Instant CORBA by Robert Orfali, Dan Harkey, and Jeri Edwards, ISBN: ■■ 0-471-18333-4. Integrating CORBA and COM Applications by Michael Rosen and ■■ David Curtis, ISBN: 0-471-19827-7. Java Programming with CORBA, Third Edition by Gerald Brose, ■■ Andreas Vogel, and Keith Duddy, ISBN: 0-471-24765-0. Mastering XMI: Java Programming with XMI, XML, and UML by ■■ Timothy J. Grose, Gary C. Doney, and Stephen A. Brodskey, ISBN: 0-471-38429-1. Model Driven Architecture: Applying MDA to Enterprise Computing by ■■ David S. Frankel, ISBN: 0-471-31920-1. The Object Technology Casebook: Lessons from Award-Winning Busi- ■■ ness Applications by Paul Harmon and William Morrisey, ISBN: 0-471-14717-6. The Object Technology Revolution by Michael Guttman and Jason ■■ Matthews, ISBN: 0-471-60679-0. Programming with Enterprise JavaBeans, JTS and OTS: Building ■■ Distributed Transactions with Java and C++ by Andreas Vogel and Madhavan Rangarao, ISBN: 0-471-31972-4. Programming with Java IDL by Geoffrey Lewis, Steven Barber, and ■■ Ellen Siegel, ISBN: 0-471-24797-9. Quick CORBA 3 by Jon Siegel, ISBN: 0-471-38935-8. ■■
  16. About the OMG The Object Management Group (OMG) is an open membership, not-for-profit consortium that produces and maintains computer-industry specifications for interoperable applications. To achieve this goal, the OMG specifies open stan- dards for every aspect of distributed computing, from analysis and design through infrastructure to application objects and components defined on vir- tually every enterprise middleware platform. OMG’s membership roster includes virtually every large company in the computer industry, and hun- dreds of smaller ones. Most of the companies that shape enterprise and Inter- net computing today are represented on OMG’s Board of Directors. OMG’s flagship specification, and the basis for future OMG specifications, is the multiplatform Model Driven Architecture (MDA). Unifying the model- ing and middleware spaces, the MDA supports applications over their entire life cycle from Analysis and Design, through implementation and deployment to maintenance and evolution. Based on normative, platform-independent Unified Modeling Language (UML) models, MDA-based applications and standards may be expressed and implemented, equivalently, on multiple mid- dleware platforms; implementations are produced automatically, for the most part, by MDA-enabled tools, which also generate cross-platform invocations, making for a truly interoperable environment. Because the UML models remain stable as the technological landscape changes around them over time, MDA-based development maximizes software ROI as it integrates applica- tions across the enterprise, and one enterprise with another. Adopted by mem- bers as the basis for OMG specifications in September 2001, the MDA is truly a unique advance in distributed computing. To learn more about the MDA, visit www.omg.org/mda. The OMG’s modeling specifications form the foundation for the MDA. These include the UML, the Meta-Object Facility (MOF), XML Metadata Interchange xvii
nguon tai.lieu . vn