OCL is well known in the Model-Based Engineering (MBE) community to specify constraints on models, using e.g., UML. See this tutorial if you need a quick refresh on the OCL language.

In the past, we have developed several MBE solutions for addressing industrial challenges related to, e.g., testing [1], product line engineering [2]. In the last few years, together with the Cancer Registry of Norway (CRN), we employed UML together with OCL to handle the ever increasing complexity of the evolving cancer registry system deployed at CRN [3]. We developed a model-based framework—MBF4CR to capture the medical domain knowledge (e.g., cancer messages) using UML and specify cancer coding rules as OCL constraints. However, when applying MBF4CR in CRN, we faced several challenges for specifying cancer coding rules with OCL. Such challenges include the fact that medical experts often have no previous experience of OCL, which hinders the application of OCL at CRN. Notably, similar challenges were observed in other contexts as well [1][2].

To address the above-mentioned challenges, we developed a web-based tool called interactive OCL (iOCL) [4] by relying on existing technologies: Eclipse Modeling Framework (EMF) [5], Eclipse OCL [6], Eclipse UML2 [7], and EsOCL [1].

The key principle of iOCL is to interactively guide users, step by step, to specify an OCL constraint, by, for instance, only giving them necessary information at a given step in the specification process. Particularly, we support three types of user operations in iOCL, i.e., selection, basic value input, and text input operations.

With the selection operation, a user selects one option from a set of valid available options, e.g., an attribute of the context class. With the basic value input operation, a user inputs basic values for basic types (e.g., Integer). Finally, with the text input operation, a user can input free text into the text box. iOCL interacts with users using these three user operations during the process of OCL constraint specification. iOCL aims at maximizing the use of the selection operation, while minimizing the use of the basic value input operation and text input operation to reduce the possibilities for users to make syntactic errors. Moreover, the increased use of selection operation can potentially reduce the required OCL knowledge since users are guided with the valid available options.

Moreover, we illustrate how iOCL is applied for specifying OCL constraints in an interactive manner using one publicly available case study named Royal and Loyal [9].

To start with iOCL, users can select an UML model with the format of .uml or .ecore (as shown in Figure 1, taking as input  model the well-known Royal and Loyal [9] example). Afterwards, iOCL automatically displays all of the model (e.g., CustomerCard and Date) in a list, from which users can select one element as context for constraint specification.

Figure 1. An illustration of iOCL (Model Upload)

Figure 1. An illustration of iOCL (Model Upload)

When a user selects the context (e.g., Membership), a list of available options is displayed in the Attribute Scope pane as shown in Figure 2, e.g., Local Attribute and Predefined Operations.

Figure 2. An Illustration of iOCL (Attribute Scope)

Figure 2. An Illustration of iOCL (Attribute Scope)

Then, if, for instance, the user selects the Predefined Operations option, iOCL automatically displays a drop-down list to show all the predefined operations, e.g., Is Null and Is Empty (as shown in Figure 3).

Figure 3. An Illustration of iOCL (Predefined Operations)

Figure 3. An Illustration of iOCL (Predefined Operations)

Once the specification process is finished,  users can click the nceValidate button to validate the syntactic correctness of the specified constraint and results will be returned to the user within a second (e.g., No Syntax Error as shown in Figure 4).

Figure 4. An Illustration of iOCL (Validation Results)

Figure 4. An Illustration of iOCL (Validation Results)

Generally speaking, iOCL was developed based on the philosophy that OCL constraints should be written in an interactive manner in practice. Note that iOCL has been currently deployed and is being tested at the CRN. Additionally, we conducted a pilot experiment to assess the applicability of iOCL in practice [8].

Based on the results of the experiment, we concluded that: 1) using iOCL can significantly reduce the time required for specifying OCL constraints as compared with writing OCL constraints without iOCL, and 2) the medical experts from CRN acknowledged that iOCL is easy to use and expressed their willingness of applying it in their practice.

Interested readers may consult our tool demo paper published in the MODELS 2016 tool demo track [4]. Also, users can try iOCL at http://iocl.zen-tools.com/ and we include examples (as mentioned above) for illustrating iOCL using RoyalAndLoyal [9]. In addition, a video related with iOCL is also available at: https://www.youtube.com/watch?v=Wgi9YYMp7Q4

We welcome any feedback or valuable comments. Please feel free to contact us at: {tao, shaukat, shuai, hammad}@simula.no


  1. Ali, S., Iqbal, M.Z., Arcuri, A., Briand, L.C.: Generating test data from OCL constraints with search techniques. IEEE Transactions on Software Engineering 39, 1376-1402 (2013)
  2. Lu, H., Yue, T., Ali, S., Zhang, L.: Model-based Incremental Conformance Checking to Enable Interactive Product Configuration. Information and Software Technology vol (72), 68-89, (2016)
  3. Wang, S., Lu, H., Yue, T., Ali, S., Nygård, J.: MBF4CR: A Model-Based Framework for Supporting an Automated Cancer Registry System. The European Conference on Modelling Foundations and Applications, pp. 191-204. Springer, (2016)
  4. Hammad, M., Yue, T., Ali, S., Wang, S.: iOCL: An Interactive Tool for Specifying, Validating and Evaluating OCL Constraints. ACM/IEEE 19th International Conference on Model Driven Engineering Languages and Systems (MODELS) Tool Demonstration Track, pp.24-31. (2016)
  5. Eclipse Modeling Framework (EMF): https://eclipse.org/modeling/emf/
  6. Eclipse OCL: http://wiki.eclipse.org/OCL
  7. Eclipse UML2: http://wiki.eclipse.org/MDT-UML2
  8. Ali, S., Hammad, M., Lu, H., Wang, S. and Yue, T.: A Pilot Experiment to Assess Interactive OCL Specification in a Real Setting. Technical report (2017-01). Available at: https://www.simula.no/publications/pilot-experiment-assess-interactive-ocl-specification-real-setting
  9. Jcabot/ocl-repository: https://github.com/jcabot/ocl-repository/
All modeling trends in your inbox

All modeling trends in your inbox

Follow the latest news on software modeling and low-code development

You have Successfully Subscribed!

Pin It on Pinterest

Share This