Time-based Constraints in the Object Constraint Language OCL

A. Hamie, J. Howse (UK), and R. Mitchell (USA)


OCL, UML, invariants, timebased constraints


The Object Constraint Language OCL is a textual specification language that supplements UML class diagrams for describing and expressing various constraints that can not be modelled by the diagrams. These constraints include invariants on classes and object types, preconditions and postconditions of operations. This paper describes an approach for extending OCL with time-based constraints in such a way so as not to compromise its simplicity. A time-based constraint describes how values can change between earlier and later states. The approach is essentially based on using @pre and oclIsNew in invariants as well as in postconditions of operations. In order to distinguish between invariants and time-based constraints we introduce the stereotype <>. We also introduce an operator eventually for expressing liveness constraints on attributes. We illustrate the approach by describing constraints such as constant attributes of an object, constant associations, and values increasing or decreasing over time.

Important Links:

Go Back