In this chapter you have learned how a model can benefit from OCL expressions. For every UML diagram, we have indicated where OCL expressions can be added. The class diagram may benefit from OCL expressions stating derivation rules, initial values, body of query operations, invariants, and preconditions and postconditions. OCL expressions can also be helpful in specifying cycles, defining derived classes, and specifying dynamic and optional multiplicity. In component or deployment diagrams, OCL expressions can be used to specify explicitly mentioned interfaces and classes. The interaction diagram and activity diagram can be improved by specifying instances and actual parameter values, and by stating conditions. The statechart may be augmented with guards , explicit targets of actions, and actual parameter values. Change events and restrictions on states can also be expressed using OCL. In a use case, the pre- and postconditions can be written using OCL. Finally, we examined different modeling styles, and learned some useful tips for building models. |