The Elements 2.0 Style
The Elements 2.0 Style
The Elements
of
TM
www.cambridge.org
Cambridge University Press 0521616786 - The Elements of UML 2.0 Style Scott W. Ambler Frontmatter More information
For Beverley
www.cambridge.org
Cambridge University Press 0521616786 - The Elements of UML 2.0 Style Scott W. Ambler Frontmatter More information
The Elements
of
TM
www.cambridge.org
Cambridge University Press 0521616786 - The Elements of UML 2.0 Style Scott W. Ambler Frontmatter More information
Cambridge,NewYork,Melbourne,Madrid,CapeTown,Singapore,SoPaulo a Cambridge University Press 40 West 20th Street, New York, NY 10011-4211, USA www.cambridge.org Information on this title: www.cambridge.org/9780521616782
C
This book is in copyright. Subject to statutory exception and to the provisions of relevant collective licensing agreements, no reproduction of any part may take place without the written permission of Cambridge University Press. First published 2005 Printed in the United States of America A catalog record for this publication is available from the British Library. Library of Congress Cataloging in Publication Data Ambler, Scott W., 1966 The elements of UML 2.0 style / Scott W. Ambler. p. cm. Includes bibliographical references and index. ISBN 0-521-61678-6 (pbk.) 1. UML (Computer science). 2. Computer software Development. I. Title. QA76.76.D47A4258 2005 005.1 dc22 2005003160 ISBN-13 978-0-521-61678-2 paperback ISBN-10 0-521-61678-6 paperback Cambridge University Press has no responsibility for the persistence or accuracy of URLs for external or third-party Internet Web sites referred to in this book and does not guarantee that any content on such Web sites is, or will remain, accurate or appropriate.
www.cambridge.org
Cambridge University Press 0521616786 - The Elements of UML 2.0 Style Scott W. Ambler Frontmatter More information
Contents
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . x Audience . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . x Assumptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . x Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.1 Organization of This Book . . . . . . . . . . . . . . . . . . . . . . . . . . 2 2. General Diagramming Guidelines . . . . . . . . . . . 4 2.1 Readability Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 2.2 Simplicity Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 2.3 Naming Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 2.4 General Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 3. Guidelines for Common UML Modeling Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.1 Guidelines for UML Notes . . . . . . . . . . . . . . . . . . . . . . . . . 3.2 Guidelines for UML Stereotypes . . . . . . . . . . . . . . . . . . . . 3.3 Guidelines for UML Frames . . . . . . . . . . . . . . . . . . . . . . . . 3.4 Guidelines for UML Interfaces . . . . . . . . . . . . . . . . . . . . . .
15 15 18 21 24
www.cambridge.org
Cambridge University Press 0521616786 - The Elements of UML 2.0 Style Scott W. Ambler Frontmatter More information
vi CONTENTS
4.3 Relationship Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 4.4 System Boundary Box Guidelines . . . . . . . . . . . . . . . . . . . 45 5. UML Class Diagrams . . . . . . . . . . . . . . . . . . . . . . . . . 47 5.1 General Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 5.2 Class Style Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 5.3 Relationship Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 5.4 Association Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 5.5 Inheritance Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 5.6 Aggregation and Composition Guidelines . . . . . . . . . . . . 70 6. UML Package Diagrams . . . . . . . . . . . . . . . . . . . . . 73 6.1 Class Package Diagram Guidelines . . . . . . . . . . . . . . . . . . . 73 6.2 Use-Case Package Diagram Guidelines . . . . . . . . . . . . . . . 76 6.3 Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 7. UML Sequence Diagrams . . . . . . . . . . . . . . . . . . . . 80 7.1 General Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 7.2 Guidelines for Lifelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 7.3 Message Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 7.4 Guidelines for Return Values . . . . . . . . . . . . . . . . . . . . . . . 91 8. UML Communication Diagrams . . . . . . . . . . . . . 94 8.1 General Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 8.2 Message Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 8.3 Link Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 9. UML State Machine Diagrams . . . . . . . . . . . . . . 9.1 General Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9.2 State Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9.3 Substate Modeling Guidelines . . . . . . . . . . . . . . . . . . . . . 9.4 Transition and Action Guidelines . . . . . . . . . . . . . . . . . . 9.5 Guard Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 103 105 106 108 111
10. UML Activity Diagrams . . . . . . . . . . . . . . . . . . . . . 113 10.1 General Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 10.2 Activity Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
www.cambridge.org
Cambridge University Press 0521616786 - The Elements of UML 2.0 Style Scott W. Ambler Frontmatter More information
CONTENTS vii
Decision Point and Guard Guidelines . . . . . . . . . . . . . 116 Parallel Flow Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . 121 Activity Partition (Swim Lane) Guidelines . . . . . . . . . . 122 Action-Object Guidelines . . . . . . . . . . . . . . . . . . . . . . . . 128
11. UML Component Diagrams . . . . . . . . . . . . . . . . 132 11.1 Component Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . 132 11.2 Dependency and Inheritance Guidelines . . . . . . . . . . . 136 12. UML Deployment Diagrams . . . . . . . . . . . . . . . 139 12.1 General Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 12.2 Node and Component Guidelines . . . . . . . . . . . . . . . . . 144 12.3 Dependency and Communication-Association . Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146 13. UML Object Diagrams . . . . . . . . . . . . . . . . . . . . . . 148 14. UML Composite Structure Diagrams . . . . . . 150 15. UML Interaction Overview Diagrams . . . . . 153 16. UML Timing Diagrams . . . . . . . . . . . . . . . . . . . . . . 157 16.1 General Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 16.2 Axis Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 16.3 Time Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 17. Agile Modeling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17.1 Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17.2 Principles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17.3 Practices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162 162 162 164
www.cambridge.org
Cambridge University Press 0521616786 - The Elements of UML 2.0 Style Scott W. Ambler Frontmatter More information
Preface
odels are used by professional developers to communicate their work to project stakeholders and to other developers. The Unied Modeling Language (UML) has been an important part of the software development landscape since its introduction in 1997. Weve seen the UML evolve over the years and it is now into its 2.x series of releases. Modeling style, however, has remained constant and will continue to do so. By understanding and following these common modeling style guidelines, you can improve the effectiveness of your models. Ive updated this book to include the new diagrams in UML 2, to use the terminology of UML 2, and to include hand-drawn diagrams. The vast majority of models are drawn on whiteboards and I think that its time that modeling books, including this one, reect that reality.
Purpose
This book describes a collection of standards, conventions, and guidelines for creating effective UML diagrams. They are based on sound, proven principles that will lead to diagrams that are easier to understand and work with. These simple, concise guidelines, if applied consistently, will be an important rst step in increasing your productivity as a modeler.
ix
www.cambridge.org
Cambridge University Press 0521616786 - The Elements of UML 2.0 Style Scott W. Ambler Frontmatter More information
x P R E FAC E
Features
This guide attempts to emulate Strunk and Whites (1979) seminal text, The Elements of Style, which lists a set of rules describing the proper application of grammatical and compositional forms in common use within the written English language. Using a similar style of presentation, this book denes a set of rules for developing high-quality UML diagrams. In doing so, this guide
employs existing standards dened by the Object Management Group (OMG) whenever possible, provides a justication for each rule, and presents standards based on real-world experience and proven principles.
Audience
This guide targets information technology (IT) professionals who are interested in
creating effective UML diagrams, increasing their productivity, and working as productive members of a software development team.
Assumptions
In this book I make several assumptions:
You understand the basics of the UML and modeling. If not, then I suggest UML Distilled (Fowler 2004) if you are looking for a brief overview of the UML, or better yet The Object Primer, third edition (Ambler 2004) for a
www.cambridge.org
Cambridge University Press 0521616786 - The Elements of UML 2.0 Style Scott W. Ambler Frontmatter More information
P R E FAC E x i
more comprehensive discussion. UML Distilled is a great book but is limited to the UML; The Object Primer, third edition, on the other hand, goes beyond the UML where needed, for example, to include user interface, Java, and database development issues. It also covers agile software development techniques in detail. You are looking for style guidelines, not design guidelines. If not, then I suggest the book Object-Oriented Design Heuristics (Riel 1996). Your focus is on business application development. Although these guidelines also apply to real-time development, all of the examples are business applicationoriented, simplications of actual systems that I have built in the past. You belong to a Western culture. Many of the layout guidelines are based on the Western approach to readingleft to right and top down. People in other cultures will need to modify these guidelines as appropriate.
Acknowledgments
The following people have provided valuable input into the development and improvement of this text: James Bielak, Chris Britton, Larry Brunelle, Lauren Cowles, Beverley Dawe, Caitlin Doggart, Doug English, Jessica Farris, Scott Fleming, Mark Graybill, Alvery Grazebrook, Jesper R. Jensen, Jon Kern, Kirk W. Knoernschild, Hubert Matthews, Les Munday, Sabine Noack, Paul Oldeld, Marco Peters, Scott W. Preece, Neil Pitman, Edmund Schweppe, Leo Tohill, Tim Tuxworth, Michael Vizdos, and Robert White.
www.cambridge.org