Learning UML 2.0 - Russ Miles.pdf - Learning UML 2.0 Other resources from O’Reilly Related titles oreilly.com UML 2.0 in a Nutshell UML Pocket

Learning UML 2.0 - Russ Miles.pdf - Learning UML 2.0 Other...

This preview shows page 1 out of 288 pages.

You've reached the end of your free preview.

Want to read all 288 pages?

Unformatted text preview: Learning UML 2.0 Other resources from O’Reilly Related titles oreilly.com UML 2.0 in a Nutshell UML Pocket Reference Prefactoring oreilly.com is more than a complete catalog of O’Reilly books. You’ll also find links to news, events, articles, weblogs, sample chapters, and code examples. oreillynet.com is the essential portal for developers interested in open and emerging technologies, including new platforms, programming languages, and operating systems. Conferences O’Reilly brings diverse innovators together to nurture the ideas that spark revolutionary industries. We specialize in documenting the latest tools and systems, translating the innovator’s knowledge into useful skills for those in the trenches. Visit conferences.oreilly.com for our upcoming events. Safari Bookshelf (safari.oreilly.com) is the premier online reference library for programmers and IT professionals. Conduct searches across more than 1,000 books. Subscribers can zero in on answers to time-critical questions in a matter of seconds. Read the books on your Bookshelf from cover to cover or simply flip to the page you need. Try it today for free. Learning UML 2.0 Russ Miles and Kim Hamilton Beijing • Cambridge • Farnham • Köln • Paris • Sebastopol • Taipei • Tokyo Learning UML 2.0 by Russ Miles and Kim Hamilton Copyright © 2006 O’Reilly Media, Inc. All rights reserved. Printed in the United States of America. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (safari.oreilly.com). For more information, contact our corporate/institutional sales department: (800) 998-9938 or [email protected] Editors: Brett McLaughlin and Mary T. O’Brien Production Editor: Laurel R.T. Ruma Copyeditor: Laurel R.T. Ruma Proofreader: Reba Libby Indexer: Angela Howard Cover Designer: Karen Montgomery Interior Designer: David Futato Cover Illustrator: Karen Montgomery Illustrators: Robert Romano, Jessamyn Read, and Lesley Borash Printing History: April 2006: First Edition. Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of O’Reilly Media, Inc. Learning UML 2.0, the image of a gorilla, and related trade dress are trademarks of O’Reilly Media, Inc. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and O’Reilly Media, Inc. was aware of a trademark claim, the designations have been printed in caps or initial caps. While every precaution has been taken in the preparation of this book, the publisher and authors assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein. This book uses RepKover™, a durable and flexible lay-flat binding. ISBN-10: 0-596-00982-8 ISBN-13: 978-0-596-00982-3 [M] [9/07] Table of Contents Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 What’s in a Modeling Language? Why UML 2.0? Models and Diagrams “Degrees” of UML UML and the Software Development Process Views of Your Model A First Taste of UML Want More Information? 2 9 12 13 13 14 16 19 2. Modeling Requirements: Use Cases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 Capturing a System Requirement Use Case Relationships Use Case Overview Diagrams What’s Next? 22 30 40 41 3. Modeling System Workflows: Activity Diagrams . . . . . . . . . . . . . . . . . . . . . . . 43 Activity Diagram Essentials Activities and Actions Decisions and Merges Doing Multiple Tasks at the Same Time Time Events Calling Other Activities Objects Sending and Receiving Signals 44 46 47 49 51 52 53 56 v Starting an Activity Ending Activities and Flows Partitions (or Swimlanes) Managing Complex Activity Diagrams What’s Next? 57 57 59 60 62 4. Modeling a System’s Logical Structure: Introducing Classes and Class Diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 What Is a Class? Getting Started with Classes in UML Visibility Class State: Attributes Class Behavior: Operations Static Parts of Your Classes What’s Next 63 67 67 72 77 79 82 5. Modeling a System’s Logical Structure: Advanced Class Diagrams . . . . . . . . 83 Class Relationships Constraints Abstract Classes Interfaces Templates What’s Next 83 91 92 96 99 100 6. Bringing Your Classes to Life: Object Diagrams . . . . . . . . . . . . . . . . . . . . . . . . 101 Object Instances Links Binding Class Templates What’s Next? 101 103 105 107 7. Modeling Ordered Interactions: Sequence Diagrams . . . . . . . . . . . . . . . . . . 108 Participants in a Sequence Diagram Time Events, Signals, and Messages Activation Bars Nested Messages Message Arrows Bringing a Use Case to Life with a Sequence Diagram Managing Complex Interactions with Sequence Fragments What’s Next? vi | Table of Contents 109 110 111 113 114 114 120 126 130 8. Focusing on Interaction Links: Communication Diagrams . . . . . . . . . . . . . . 131 Participants, Links, and Messages Fleshing out an Interaction with a Communication Diagram Communication Diagrams Versus Sequence Diagrams What’s Next? 131 136 139 143 9. Focusing on Interaction Timing: Timing Diagrams . . . . . . . . . . . . . . . . . . . . 144 What Do Timing Diagrams Look Like? Building a Timing Diagram from a Sequence Diagram Applying Participants to a Timing Diagram States Time A Participant’s State-Line Events and Messages Timing Constraints Organizing Participants on a Timing Diagram An Alternate Notation What’s Next? 144 146 147 148 149 152 153 154 157 159 162 10. Completing the Interaction Picture: Interaction Overview Diagrams . . . . 163 The Parts of an Interaction Overview Diagram Modeling a Use Case Using an Interaction Overview What’s Next? 163 165 171 11. Modeling a Class’s Internal Structure: Composite Structures . . . . . . . . . . . 173 Internal Structure Showing How a Class Is Used Showing Patterns with Collaborations What’s Next? 174 180 182 185 12. Managing and Reusing Your System’s Parts: Component Diagrams . . . . . . 186 What Is a Component? A Basic Component in UML Provided and Required Interfaces of a Component Showing Components Working Together Classes That Realize a Component Ports and Internal Structure Black-Box and White-Box Component Views What’s Next? 186 187 188 190 192 194 196 197 Table of Contents | vii 13. Organizing Your Model: Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198 Packages Namespaces and Classes Referring to Each Other Element Visibility Package Dependency Importing and Accessing Packages Managing Package Dependencies Using Packages to Organize Use Cases What’s Next? 199 201 203 204 205 208 209 210 14. Modeling an Object’s State: State Machine Diagrams . . . . . . . . . . . . . . . . . . 211 Essentials States Transitions States in Software Advanced State Behavior Composite States Advanced Pseudostates Signals Protocol State Machines What’s Next? 212 213 214 217 218 220 221 222 223 223 15. Modeling Your Deployed System: Deployment Diagrams . . . . . . . . . . . . . . . 224 Deploying a Simple System Deployed Software: Artifacts What Is a Node? Hardware and Execution Environment Nodes Communication Between Nodes Deployment Specifications When to Use a Deployment Diagram What’s Next? 224 226 229 229 231 232 234 235 A. Object Constraint Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237 B. Adapting UML: Profiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245 C. A History of UML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259 viii | Table of Contents Preface 1 The Unified Modeling Language (UML) is the standard way to model systems, particularly software systems. If you are working on a system beyond “Hello, World,” then having UML in your toolbox of skills is a must, and that’s where Learning UML 2.0 comes in. Learning UML 2.0 is about coming to grips with UML quickly, easily, and practically. Along with a thorough set of tutorials on each of the different UML diagram types, this book gives you the tools to use UML effectively when designing, implementing, and deploying systems. The topics covered include: • A brief overview of why it is helpful to model systems • How to capture high-level requirements in your model to help ensure the system meets users’ needs • How to model the parts that make up your system • How to model the behavior and interactions between parts when the system is running • How to move from the model into the real world by capturing how your system is deployed • How to create custom UML profiles to accurately model different system domains Audience Learning UML 2.0 is for anyone interested in learning about UML, but it is helpful to have some exposure to object-oriented (OO) design and some familiarity with Java. However, even if you have only a small amount of experience with object orientation, Learning UML 2.0 will improve and extend your knowledge of OO concepts and give you a comprehensive set of tools to work with UML. Although this book is intended to take you through each subject on the path to learning UML, some UML modeling subjects, such as use cases and activity diagrams, are self-explanatory, which means you can dive right into them. Preface | This is the Title of the Book, eMatter Edition Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved. ix About This Book Learning UML 2.0 aims to answer the “what,” “how,” and “why should I care?” for every aspect of UML. Each chapter picks one subject from UML and explains it based on these questions. Since not everyone is new to UML, there are two main routes through this book. If you’re new to UML as a subject and want to get an overview of where the modeling language came from, then you should start with Chapter 1. However, if you want to get your hands dirty as quickly as possible, then you can either skip the introduction chapter to delve directly into use cases or jump to the chapter that describes the UML diagram in which you are most interested. Now you know what Learning UML 2.0 is about, it should be explained what this book is not about. This book is not about any one particular modeling tool or implementation language. However, some tools have their own way of doing things, and some implementation languages do not support everything you can legally model in UML. Wherever appropriate, we have tried to point out where UML tools or implementation languages deviate from or follow the UML standard. Lastly, because of the large variation in software development processes, this book is not about any particular process or methodology. Instead, it focuses on modeling and provides guidelines about appropriate levels of modeling that can be applied in the context of your software development process. Since this book adheres to the UML 2.0 standard, it works alongside any process or methodology you use. Assumptions This Book Makes The following general assumptions are made as to the reader’s knowledge and experience: • An understanding of object orientation • Knowledge of the Java™ language for some of the examples Conventions Used in This Book The following typographical conventions are used in this book: Italic Indicates new terms, URLs, email addresses, filenames, file extensions, pathnames, directories, and Unix utilities. Constant width Indicates commands, options, switches, variables, attributes, keys, functions, types, classes, namespaces, methods, modules, properties, parameters, values, objects, events, event handlers, XML tags, HTML tags, macros, the contents of files, or the output from commands. x | Preface This is the Title of the Book, eMatter Edition Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved. Constant width bold Shows commands or other text that should be typed literally by the user. Constant width italic Shows text that should be replaced with user-supplied values. This icon signifies a tip, suggestion, or general note. This icon indicates a warning or caution. Using Code Examples This book is here to help you get your job done. In general, you may use the code in this book in your programs and documentation. You do not need to contact us for permission unless you’re reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from O’Reilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your product’s documentation does require permission. We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: “Learning UML 2.0, by Russ Miles and Kim Hamilton. Copyright 2006 O’Reilly Media, Inc., 0-596-00982-8.” If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at [email protected] Safari® Enabled When you see a Safari® Enabled icon on the cover of your favorite technology book, that means the book is available online through the O’Reilly Network Safari Bookshelf. Safari offers a solution that’s better than e-books. It’s a virtual library that lets you easily search thousands of top tech books, cut and paste code samples, download chapters, and find quick answers when you need the most accurate, current information. Try it for free at . Preface | This is the Title of the Book, eMatter Edition Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved. xi How to Contact Us Everything has been done to ensure that the examples within this book are accurate, tested, and verified to the best of the authors’ ability. However, even though UML is a standard modeling language, the best practices as to its usage may change with time and this may have an impact on this book’s contents. If so, please address comments and questions concerning this book to the publisher: O’Reilly Media, Inc. 1005 Gravenstein Highway North Sebastopol, CA 95472 (800) 998-9938 (in the United States or Canada) (707) 829-0515 (international or local) (707) 829-0104 (fax) There is a web page for this book where you can find errata, examples, and any additional information. You can access this page at: To comment or ask technical questions about this book, email: [email protected] For more information about our books, conferences, Resource Centers, and the O’Reilly Network, see our web site: Additional information about this topic, including exercises, can be found at: Acknowledgments From the Authors Thanks to Brett and Mary, our ace editors. We are indebted to Brett for providing valuable guidance throughout, and to Mary for her UML expertise, her amazing work bringing this book to completion, and her ability to line up an outstanding team of reviewers. We’d also like to thank all the kind individuals who put in the hours to provide such excellent technical feedback on this book. Thanks to Ed Chou, Glen Ford, Stephen Mellor, Eric Naiburg, Adewale Oshineye, Dan Pilone and Neil Pitman, and Richard Mark Soley (the history of UML would not have been nearly as interesting without your help). xii | Preface This is the Title of the Book, eMatter Edition Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved. From Russ Miles First and foremost, my thanks go to my family and friends: Mum, Dad, Bobbie, Rich, Ad, Corinne (thanks for all your help through the last hectic stages, you’re one in a million!), Martin and Sam, Jason and Kerry, and Aimee (wonder dog!). You are always there for me 100 percent and, as a bonus, have the uncanny but very useful ability to get me away from the Mac once in a while when I really need it. I’d also like to take this opportunity to thank my uncle, Bruce Sargent. You got me started on the first steps in this career and for that I am, and always will be, very grateful! I’d like to thank all my proofreaders, including Rob Wilson, Laura Paterson, and Grant Tarrant-Fisher. You’ve been great proofreaders, tech reviewers and, most of all, friends. With your comments this a much better book than anything I could have put together on my own. Also, a special thanks to Rachel “Kong” Stevens for being the unwitting inspiration for the front cover—we love ya! A big thanks must go to M. David Peterson ( ) and Sylvain Hellegouarch ( ) for all their help and inspiration with the CMS example that is used throughout this book. You’re both top bloggers, developers, and friends and I want to say thanks to you and all the LLUP hackers ( . x2x2x.org/projects/wiki) for making my coding life that much more interesting, cheers! Last, but not least—with what is quickly becoming a standard catch-all—thanks to everyone who has helped me out while writing this book. I haven’t forgotten your help and I know I owe you all a beer or two! From Kim Hamilton Thanks again to Ed Chou for his gaming expertise that helped create the FPS example (among his many other excellent contributions!) and for the long hours spent reviewing this book at every phase. A big thanks goes to my reviewers: Frank Chiu, Albert Chu, Yu-Li Lin, Justin Lomheim, Samarth Pal, Leland So, and Delson Ting. You were great at everything—from providing technical feedback to pointing out the humor in the word OMG. Thanks to John Arcos, Ben Faul, Mike Klug, Dwight Yorke, and Paul Yuenger, whose support helped me get this book out the door. Also, thanks to Thomas Chen for his CMS help! Most of all, thanks to my wonderful family and friends—Mom, Dad, Ron, Mark, Grandma and Ed, Grandpa (in loving memory), Aunt Gene, Anne Marie, Kim, Ed C, Sokun, and Tien—who have all been so supportive this past year. Special thanks to my Mom and Dad: my Mom keeps me going with her love, friendship, and phone calls; and my Dad has always been my number one technical mentor. Preface | This is the Title of the Book, eMatter Edition Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved. xiii Chapter 1 CHAPTER 1 Introduction 1 The Unified Modeling Language (UML) is the standard modeling language for software and systems development. This statement alone is a pretty conclusive argument for making UML part of your software repertoire, however it leaves some questions unanswered. Why is UML unified? What can be modeled? How is UML a language? And, probably most importantly, why should you care? Systems design on any reasonably large scale is difficult. Anything from a simple desktop application to a full multi-tier enterprise scale system can be made up of hundreds—and potentially thousands—of software and hardware components. How do you (and your team) keep track of which components are needed, what their jobs are, and how they meet your customers’ requirements? Furthermore, how do you share your design with your colleagues to ensure the pieces work together? There are just too many details that can be misinterpreted or forgotten when developing a complex system without some help. This is where modeling—and of course UML— comes in. In systems design, you model for one important reason: to manage complexity. Modeling helps you see the forest for the trees, allowing you to focus on, capture, document, and communicate the im...
View Full Document

  • Fall '14

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes
A+ icon
Ask Expert Tutors