ACCU Home page ACCU Conference Page
Search Contact us ACCU at Flickr ACCU at GitHib ACCU at Facebook ACCU at Linked-in ACCU at Twitter Skip Navigation

Search in Book Reviews

The ACCU passes on review copies of computer books to its members for them to review. The result is a large, high quality collection of book reviews by programmers, for programmers. Currently there are 1949 reviews in the database and more every month.
Search is a simple string search in either book title or book author. The full text search is a search of the text of the review.
    View all alphabetically
The Object Constraint Language
J Warmer&A Kleppe
0 201 37940 6
Richard Blundell
modelling languages
Appeared in:
The Object Constraint Language (OCL) is a simple but formal declarative language for specifying constraints, or 'universal truths,' about a system or a model of one. It is powerful enough to specify conditions of almost any level of complexity in an unambiguous manner, yet has been designed to be easy to learn and comprehend. It is more precise than 'natural language' descriptions, yet is much more intelligible than some other formal mathematical languages.

I know of only two ways that you can learn about OCL. First you can download the latest version (currently V1.3 alpha R5) of the UML documentation from the OMG web site ( and look up section six, which is the OCL specification (and which is surprisingly readable for a standard document). Second you can read this book. Jos Warmer is the original IBM author of OCL and is currently responsible for the development of that part of the UML standard.

With a few exceptions, this book is quite similar in content to the standard document and they are both refreshingly concise (the standard is currently just 48 US-letter pages). Chapter one discusses why constraints are useful in modelling, including a discussion of design by contract using invariants, pre- and post-conditions. Chapter two covers OCL basics - the writing of simple constraints on attributes, classes and methods. Chapter three is a complete summary of OCL, basic operations and precedence, built in types such as Real and String, model types from the UML model and the collection types set, bag and sequence. Chapter four is a useful discussion of the use of constraints in modelling - a topic that is not covered in the standard. The short fifth chapter advises on ways to extend OCL consistently. Appendix A is a handy list of all the operations supported by the built in types and collections and Appendix B is a subset of the formal grammar. Both of these appendices are reproduced verbatim from the 1.1 version of the standard.

Although only published in October 1998, the book is out of date or incomplete in a few places with respect to the latest version of the standard, sometimes quite significantly. For example, the order of operator precedence has changed. The grammar in the appendix has since been extended to include explicit specification of context objects and operations with formal parameter lists, as well as the 'inv,' 'pre' and 'post' stereotypes, although these are explained in the text. There are also a number of technical errors in the examples. Having said that, the OCL standard itself is still evolving and I uncovered a number of errors in the current version of the standard document itself (which should be corrected in V1.4 due April 1999).

If you want to learn OCL, this is an accessible place to start and the section on modelling guidance was quite useful. However, be wary of the examples whilst learning and I would urge you also to download the most up-to-date version of the standard and consult that as a reference once you are up to speed with the concepts of OCL.