Practical Object-Oriented Design With UML
Practical Object-Oriented Design With UML
Practical
Object-Oriented
Design With
UML
Second Edition
PRACTICAL OBJECT-ORIENTED DESIGN WITH UML
Second Edition
PRACTICAL OBJECT-ORIENTED DESIGN
WITH UML
Second Edition
Mark Priestley
Preface xi
1 Introduction to UML 1
1.1 Models and modelling 1
1.2 Methodologies 5
1.3 The Unified Modeling Language 7
1.4 Design models and code 11
1.5 The software development process 12
1.6 Summary 12
1.7 Exercises 13
v
vi CONTENTS
10 Statecharts 208
10.1 State-dependent behaviour 209
10.2 States, events and transitions 210
10.3 Initial and final states 211
10.4 Guard conditions 212
10.5 Actions 214
10.6 Activities 216
10.7 Composite states 218
10.8 History states 221
10.9 Summary of the CD player 222
10.10 Dynamic modelling in practice 223
10.11 Time events 228
10.12 Activity states 228
10.13 Summary of the ticket machine 229
10.14 Summary 229
10.15 Exercises 231
12 Constraints 248
12.1 Standard constraints 249
12.2 The Object Constraint Language 250
12.3 The context of a constraint 251
12.4 Navigation expressions 253
12.5 OCL data types and operations 256
12.6 Constraints 260
12.7 Stereotyped constraints 263
12.8 Constraints and generalization 266
12.9 Summary 267
12.10 Exercises 268
Index 353
PREFACE
Italo Calvino
xi
xii PRACTICAL OBJECT- ORIENTED DESIGN WITH UML
This objective of course places limits on the size of the example that can be
considered. To get round this, the book takes as its paradigm system architecture
a typical stand-alone desktop application, supporting a graphical user interface and
interfacing to a relational database. Within this framework, the text examines the
development of some core functionality, and leaves extensions of the system to be
worked out as exercises.
The second objective is to provide a tutorial introduction to those aspects of UML
that are important in developing this kind of application. Much emphasis is placed on
clearly explaining the constructs and notation of the design language, and demonstrating
the close relationship between the design and the implementation of object-oriented
programs. These issues are treated rather superficially in many books. If they are not
clearly understood, however, it is difficult to make correct use of UML.
UML is a large and complex language, and when one is learning it there is a danger
of being overwhelmed by details of the notation. In order to avoid this, the book uses a
subset of UML that is sufficient to develop desktop applications. The most significant
omissions are any coverage of concurrency, activity diagrams and anything other than
a brief mention of deployment diagrams. These aspects of the language are obviously
important for ‘industrial-strength’ applications of UML, but these lie somewhat outside
the experience of the intended audience of this book.
Introductory
Chapters 1 and 2
Other topics
Chapters 13 and 14
The most significant change in the second edition is that the diagram editor example has
been replaced by a new case study based on a simple booking system for a restaurant.
This provides an application with more ‘real-world’ context than the diagram editor, and
is one which many students find easier to relate to. It also allows concepts of different
architectural layers to be introduced more naturally than before, and these topics are
now covered explicitly in Chapters 4 to 7.
Although the focus of the book is on language rather than process, it is impossible
to divorce the two entirely in any practical approach. In the new Chapter 3, the book now
includes an explicit discussion of some issues in the development of software processes
and provides an outline sketch of the Unified Process.
The remaining chapters are very much the same as in the previous edition, though
minor changes have been made throughout the book, both in content and presentation.
To make room for the new chapter and case study, some material has had to be omitted
from this edition, most noticeably the second case study. All the material that has been
omitted, including the diagram editor example, will be made available from book’s
website.
FURTHER RESOURCES
A web page for the book provides access to the source code for the examples used in
the book, solutions to all exercises and material from the first edition. It can be found at
the following URL:
http://www.mcgraw-hill.co.uk/textbooks/priestley
An instructor’s manual, including slides, the diagrams used in the book and
additional exercises, is available to bona fide academics who have adopted the book for
classroom use. Information on how to obtain the manual can be found on the publisher’s
website.
ACKNOWLEDGEMENTS
In the preparation of this new edition, my most significant debt is to my students who
have made use of the earlier editions, and also sat through earlier presentations of the
restaurant booking system. I am indebted to Michael Richards for the initial idea for
this case study.