Ocl (Object Constraint Language)
The Object Constraint Language (OCL) is not a programming language; it is a formal expression language used to express constraints and conditions on object-oriented models. The evaluation of an OCL expression always delivers a value. It does not change anything in the system model. As an expression language OCL is also neutral about implementation decisions. This means that the usage of OCL is not tied to any specific platform or programming language.
The OCL is a subset of the UML (Unified Modeling Language), which is mainly used for documentation. Based on the Syntropy object-oriented analysis and design method, the OCL was originally developed within IBM as a language for business modeling. One of the guidelines of the OCL was that an easy-to-use standard was needed to document constraints. It was incorporated into the UML 1.1 specification in 1997 and is considered the standard notation for constraints on object-oriented systems.
A constraint is a restriction or set of rules that governs an object. The context of the constraint is the attribute, method, class, or other object that is being constrained. These constraints may be noted within the UML diagram or documented separately.
Constraints and conditions provide an additional level of detail not provided by standard UML diagrams. This additional detail helps formalize system requirements. Without the OCL, additional information to clarify models could be written in natural language. However, as natural language varies between modelers, it is prone to ambiguity and misinterpretation. The OCL provides a textual description of constraints on attributes, methods, and classes within object-oriented models. As a formal language for constraint notation, the OCL reduces ambiguity and increases precision of the system descriptions.
Specific types of constraints include invariants, preconditions, postconditions, and guards. An invariant is a condition that must be met at all times by all instances of the class or type. A precondition is a condition that must be true at the moment of execution of an operation. A postcondition is a condition that must be true at the moment after execution of an operation. A guard is a constraint that must be true before a state transition occurs.
OCL is a typed language, meaning that part of the definition of the OCL includes value types. The basic predefined types are Boolean, integer, string, and real. Additionally there are more advanced types, including collection types, meta types, and user-defined types. Various operations can be performed on each value types as part of evaluating an OCL expression. For example, operations for the integer and real types include mathematical functions.
This is the complete article, containing 420 words
(approx. 1 page at 300 words per page).