Home Learn more about OCL Rational Rose OCL-AddIn product description Downloads Buy our products Support information Sitemap Contact Privacy policy  
Benefits

Although the UML contains a lot of diagram elements, e.g. class diagrams, activity diagrams, state charts and more, these diagrams cannot be used to specify calculations on the objects of your software systems.
Nevertheless, in any non trivial software system there is a huge amount of information of this type that needs to be clearly understood by all people involved in the creation of the system, be they business analysts, designers, coders, testers or technical writers.
For example, you might need to capture the information, that an applicant for an insurance must be at least 18 years old.

Traditionally, you would add some notes to your class diagrams or you would extend an UML Use Case and add a textual description of this requirement:

An applicant must be at least 18 years old.

But this approach has a number of drawbacks:

  • If the expressions become more complex, ambiguities will arise. The danger of misinterpreting the rule increases.
  • No consistency checks can be done because the expression is not made in a formal language. For example, the statement could refer to an attribute or association that was removed or whose type and thus probably its semantics have changed.
  • It is not possible to extract concise lists of constraints, which is essential for testers and technical writers.
  • The expressions cannot be reused to generate code.

Using OCL, the situation improves massively:

Avoiding Ambiguity

Being a formal language, the expression becomes unambiguous. The knowledge gathered by the business analysts can be captured without loss.

Ensuring Consistency

The business knowledge that is expressed as OCL expressions is stored where it should be stored: in your UML model, together with all the other elements and definitions that form the foundation of your software system.
Complete checking of the expression is possible. Thus errors are detected immediately during editing the expression and the danger of errors is greatly reduced. If an expression becomes outdated because of changes in the model, this is also indicated. The consistency of the OCL expressions and the rest of the model is thus ensured.

Enabling Additional Processing

Since the OCL expressions are maintained as dedicated model elements, it is possible to extract and process these elements. E.g. it is possible to generate reports of all specified constraints as a reference for testers and technical writers.

Generating Code From OCL Expressions

If you are using an MDA-like approach, the code generators can use the OCL expressions to automatically create assert-statements or method implementations for get-methods. Since the abstraction level of OCL is significantly higher than with traditional object oriented programming languages, this approach results in a reduction of the error rate. In addition, this allows reuse of the captured business rules on all supported target platforms.

Discover sloppy specifications

In a sense, the most important benefit of using OCL is that thinking about a precise specification of the systems requirements helps you to gain a better and more complete understanding of the system. This, in turn, makes your implementation phase more effective.
Page last modified: 2009-12-01 22:13:23