More than 20 years after the creation of the Object Constraint Language (OCL), the number of tools supporting is still rather small. Of course, most UML tools let you annotate the models with comments where you could write plain textual OCL expressions. But most times, the tool doesn’t really understand that text, you could write anything there, for instance, a wrong OCL constraint. To qualify as an OCL tool, we require that the tool is, at the very least, able to parse the OCL expression. Bonus point if it lets you execute & evaluate it over a sample set of objects.
First generation of OCL tools
In the 2008 edition of the OCL workshop, we organized a tool showcase where a number of (prototype) OCL tools were presented. For a more deep survey of OCL tools (really old, as such, not useful for the list of tools per se but I still think it’s an interesting read to learn more about what I think OCL tools should provide) you can check: Jordi Cabot, Ernest Teniente: Constraint Support in MDA Tools: A Survey. ECMDA-FA 2006: 256-267 ( free pdf). In this blog, we have also presented Oclarity, a productive authoring environment for the writing of OCL expressions, and iOCL an interactive OCL environment. Both are currently discontinued. In fact, many of these older tools have disappeared and the issue is that we do not have many more recent tools to replace them. From a more code-generation perspective, we also had couple of tools specialized in OCL to SQL generation.
Best free OCL tools
The two best free OCL options nowadays are clearly the OCL Eclipse plug-in (OCLInEcore) and the USE tool.
Eclipse OCL is ideal to integrate OCL support in your model-driven tool chain. As part of the Eclipse Modeling technologies, it’s easy to combine with other tools for model transformation, code-generation,… and enrich them with OCL processing capabilities.
USE is better if your goal “play” with OCL, exploring the result of OCL expressions in sample object diagrams. For instance, to see if your OCL constraints are consistent (see also our USE extension to help you to debug inconsistent constraints) and, if so, if they properly encode the business rules of the domain as maybe they are too restrictive or, the other way round, they are too permissive and need to be strengthened. Moreover, USE comes with a language (ASSL) to automatically create model instances that you could use for validation purposes in different scenarios.
OCL support in commercial UML tools
On the commercial side, MagicDraw also understands OCL and allows you to write (only boolean) OCL queries to test them.
Enterprise architect is also able to check the proper syntax of OCL expressions added to UML models.
Experimental OCL tools
There are also a few tools more specialized to support OCL for specific tasks or specific tech stacks.
OCL embedded in other model-driven tools
Despite the lack of support for “end-user” facing tools, OCL is recognized as a useful model query and manipulation language and as such it’s often used in model transformation and code-generation tools, such as ATL or Acceleo to create new modeling artefacts that will then be used as part of more complex MDE pipeliines.
This is good news for OCL but still doesn’t fix the problem of not offering an easy option for designers that just want to add some OCL invariants or pre/postconditions to their UML class diagrams in order to have more precise models.
Btw, while looking for an OCL tool, you may want to improve your Object Constraint Language knowledge by checking out our OCL tutorial. And when more vendors decide to join this club, we even have already thought on a benchmark for evaluating OCL tools.