More than 20 years after the creation of the Object Constraint Language (OCL), the number of tools supporting is still rather small. In fact, I have the feeling that it’s even decreasing.
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.
Contents
B-OCL: Our own OCL tool
To counter this lack of OCL tools (see the few exceptions below), we decided to built the first-ever open source OCL tool in python language. Read the announcement. The beta version is available on GitHub and it is ready to use. The tool is a great complement to our OSS low-modeling low-code BESSER platform but it could be easily used with other tools.
Our OCL tool support has two main components:
- An OCL metamodel and grammar+parser so you are able to annotate your UML models with OCL constraints. Or better said, with B-OCL constraints as we don’t claim to have fully compliant support with the OCL standard but a more pragmatic approach for now.
- An OCL interpreter that adds the capability to actually execute those constraints and evaluate them on top of an object model, where each object is an instance of a B-UML class. The figure below shows the workflow for our B-OCL interpreter
Give it a try and let us know what you think!
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 a couple of tools specialized in OCL to SQL generation.
Best free OCL tools
Beyond our own one 😅, 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 can also 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.
For instance, SimpleOCL is an OCL component designed to be embedded in other modeling tool mostly for transformation purposes. And we have also a tool for writing and evaluating OCL expressions in JavaScript. Back to a more traditional Java implementation (same language beneath Eclipse OCL and USE), Aocl is a more pure Java implementation of OCL that makes it easy to integrate OCL expressions in Java programs.
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.
Recent Comments