Description:
C/C++ programmers commonly use assert statements to ensure program values are within range. You may be surprised to learn that the ability to model such constraints is now built into the Unified Modeling Language (UML) v. 1.1 in the form of the Object Constraint Language (OCL). The Object Constraint Language shows that with simple, elegant OCL statements, a UML design can be made more logically robust and easy to understand. The book begins with the ideas behind OCL, that it must model constraints as simply as possible. (Early formal languages such as Z and Larch often relied on mathematical symbols; not so with OCL.) The authors show that OCL can be used to model invariants (which apply conditions to classes) and in pre- and postconditions, which can be used to constrain operations of a class. The second chapter models a simple credit card bonus program (where credit card users can earn bonus points for using their cards according to known rules). This example is good because it lets the authors show how limiting conditions can enhance a UML design. They introduce the basic data types available in OCL, as well as collections of objects such as sets, bags, and sequences. Further sections cover advanced features, including working with collections and resolving ambiguous conditions. The authors provide hints for using OCL effectively, as well as extending OCL in new ways. (The motto here is simplicity first.) A handy appendix on OCL ensures that this very concise--yet useful--guide will bring the reader up to date on an important capability available in today's UML standard. --Richard Dragan
|