For Beverley
Scott W. Ambler
CAMBRIDGE UNIVERSITY PRESS
Cambridge, New York, Melbourne, Madrid, Cape Town, Singapore, São Paulo
Cambridge University Press
40 West 20th Street, New York, NY 10011-4211, USA
www.cambridge.org
Information on this title: www.cambridge.org/9780521616782
© Cambridge University Press 2005
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.
| 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 | 15 | |
| 3.1 | Guidelines for UML Notes | 15 | |
| 3.2 | Guidelines for UML Stereotypes | 18 | |
| 3.3 | Guidelines for UML Frames | 21 | |
| 3.4 | Guidelines for UML Interfaces | 24 | |
| 4. | UML Use-Case Diagrams | 33 | |
| 4.1 | Use-Case Guidelines | 33 | |
| 4.2 | Actor Guidelines | 35 | |
| 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 | 103 | |
| 9.1 | General Guidelines | 103 | |
| 9.2 | State Guidelines | 105 | |
| 9.3 | Substate Modeling Guidelines | 106 | |
| 9.4 | Transition and Action Guidelines | 108 | |
| 9.5 | Guard Guidelines | 111 | |
| 10. | UML Activity Diagrams | 113 | |
| 10.1 | General Guidelines | 113 | |
| 10.2 | Activity Guidelines | 116 | |
| 10.3 | Decision Point and Guard Guidelines | 116 | |
| 10.4 | Parallel Flow Guidelines | 121 | |
| 10.5 | Activity Partition (Swim Lane) Guidelines | 122 | |
| 10.6 | 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 | 162 | |
| 17.1 | Values | 162 | |
| 17.2 | Principles | 162 | |
| 17.3 | Practices | 164 | |
| Bibliography | 165 | ||
| Index | 169 | ||
Models are used by professional developers to communicate their work to project stakeholders and to other developers. The Unified Modeling Language (UML) has been an important part of the software development landscape since its introduction in 1997. We’ve 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.
I’ve 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 it’s time that modeling books, including this one, reflect that reality.
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 first step in increasing your productivity as a modeler.
This guide attempts to emulate Strunk and White’s (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 defines a set of rules for developing high-quality UML diagrams. In doing so, this guide
■ employs existing standards defined by the Object Management Group (OMG) whenever possible,
■ provides a justification for each rule, and
■ presents standards based on real-world experience and proven principles.
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.
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 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 application–oriented, simplifications 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 reading—left to right and top down. People in other cultures will need to modify these guidelines as appropriate. |
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 Oldfield, Marco Peters, Scott W. Preece, Neil Pitman, Edmund Schweppe, Leo Tohill, Tim Tuxworth, Michael Vizdos, and Robert White.