Optimising OCL Synthesized Code

  • Jesús Sánchez CuadradoEmail author
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 10890)


OCL is a important element of many Model-Driven Engineering tools, used for different purposes like writing integrity constraints, as navigation language in model transformation languages or to define transformation specifications. There are refactorings approaches for manually written OCL code, but there is not any tool for the simplification of OCL expressions which have been automatically synthesized (e.g., by a repair system). These generated expressions tend to be complex and unreadable due to the nature of the generative process. However, to be useful this code should be as simple and resemble manually written code as much as possible.

In this work we contribute a set of refactorings intended to optimise OCL expressions, notably covering cases likely to arise in generated OCL code. We also contribute the implementation of these refactorings, built as a generic transformation component using bentō, a transformation reuse tool for ATL, so that it is possible to specialise the component for any OCL variant based on Ecore. We describe the design and implementation of the component and evaluate it by simplifying a large amount of OCL expressions generated automatically showing promising results. Moreover, we derive implementations for ATL, EMF/OCL and SimpleOCL.


Model-Driven Engineering Model transformations OCL Refactoring 



Work funded by the Spanish MINECO TIN2015-73968-JIN (AEI/FEDER/UE).


  1. 1.
    Ackermann, J., Turowski, K.: A library of OCL specification patterns for behavioral specification of software components. In: Dubois, E., Pohl, K. (eds.) CAiSE 2006. LNCS, vol. 4001, pp. 255–269. Springer, Heidelberg (2006). Scholar
  2. 2.
    Arendt, T., Biermann, E., Jurack, S., Krause, C., Taentzer, G.: Henshin: advanced concepts and tools for in-place EMF model transformations. In: Petriu, D.C., Rouquette, N., Haugen, Ø. (eds.) MODELS 2010. LNCS, vol. 6394, pp. 121–135. Springer, Heidelberg (2010). Scholar
  3. 3.
    Bracha, G., Ungar, D.: OOPSLA 2004: mirrors: design principles for meta-level facilities of object-oriented programming languages. ACM SIGPLAN Not. 50(8), 35–48 (2015)CrossRefGoogle Scholar
  4. 4.
    Bravenboer, M., Kalleberg, K.T., Vermaas, R., Visser, E.: Stratego/XT 0.17. A language and toolset for program transformation. Sci. Comput. Program. 72(1–2), 52–70 (2008)MathSciNetCrossRefGoogle Scholar
  5. 5.
    Cabot, J., Teniente, E.: Transformation techniques for OCL constraints. Sci. Comput. Program. 68(3), 179–195 (2007)MathSciNetCrossRefGoogle Scholar
  6. 6.
    Correa, A., Werner, C.: Refactoring object constraint language specifications. Softw. Syst. Model. 6(2), 113–138 (2007)CrossRefGoogle Scholar
  7. 7.
    Correa, A., Werner, C., Barros, M.: An empirical study of the impact of OCL smells and refactorings on the understandability of OCL specifications. In: Engels, G., Opdyke, B., Schmidt, D.C., Weil, F. (eds.) MODELS 2007. LNCS, vol. 4735, pp. 76–90. Springer, Heidelberg (2007). Scholar
  8. 8.
    Cuadrado, J.S., Guerra, E., de Lara, J.: A component model for model transformations. IEEE Trans. Softw. Eng. 40(11), 1042–1060 (2014)CrossRefGoogle Scholar
  9. 9.
    Sánchez Cuadrado, J., Guerra, E., de Lara, J.: Reverse engineering of model transformations for reusability. In: Di Ruscio, D., Varró, D. (eds.) ICMT 2014. LNCS, vol. 8568, pp. 186–201. Springer, Cham (2014). Scholar
  10. 10.
    Cuadrado, J.S., Guerra, E., de Lara, J.: Reusable model transformation components with bentō. In: Kolovos, D., Wimmer, M. (eds.) ICMT 2015. LNCS, vol. 9152, pp. 59–65. Springer, Cham (2015). Scholar
  11. 11.
    Cuadrado, J.S., Guerra, E., de Lara, J.: Quick fixing ATL transformations with speculative analysis. Softw. Syst. Model. 1–35 (2016)Google Scholar
  12. 12.
    Cuadrado, J.S., Guerra, E., de Lara, J.: Static analysis of model transformations. IEEE Trans. Softw. Eng. 43(9), 868–897 (2017)CrossRefGoogle Scholar
  13. 13.
    Cuadrado, J.S., Guerra, E., de Lara, J.: AnATLyzer: an advanced IDE for ATL model transformations. In: 40th International Conference on Software Engineering (ICSE). ACM/IEEE (2018)Google Scholar
  14. 14.
    Cuadrado, J.S., Guerra, E., de Lara, J., Clarisó, R., Cabot, J.: Translating target to source constraints in model-to-model transformations. In: 2017 ACM/IEEE 20th International Conference on Model Driven Engineering Languages and Systems (MODELS), pp. 12–22. IEEE (2017)Google Scholar
  15. 15.
    Sánchez Cuadrado, J., Jouault, F., García Molina, J., Bézivin, J.: Optimization patterns for OCL-based model transformations. In: Chaudron, M.R.V. (ed.) MODELS 2008. LNCS, vol. 5421, pp. 273–284. Springer, Heidelberg (2009). Scholar
  16. 16.
    de Lara, J., Guerra, E.: From types to type requirements: genericity for model-driven engineering. Softw. Syst. Mod. 12(3), 453–474 (2013)CrossRefGoogle Scholar
  17. 17.
    Eclipse Modelling Framework.
  18. 18.
  19. 19.
    Giese, M., Larsson, D.: Simplifying transformations of OCL constraints. In: Briand, L., Williams, C. (eds.) MODELS 2005. LNCS, vol. 3713, pp. 309–323. Springer, Heidelberg (2005). Scholar
  20. 20.
    Hassam, K., Sadou, S., Le Gloahec, V., Fleurquin, R.: Assistance system for OCL constraints adaptation during metamodel evolution. In: 2011 15th European Conference on Software Maintenance and Reengineering (CSMR), pp. 151–160. IEEE (2011)Google Scholar
  21. 21.
    Jouault, F., Allilaire, F., Bézivin, J., Kurtev, I.: ATL: a model transformation tool. Sci. Comput. Program. 72(1–2), 31–39 (2008). Accessed Nov 2010MathSciNetCrossRefGoogle Scholar
  22. 22.
    Loveman, D.B.: Program improvement by source-to-source transformation. J. ACM (JACM) 24(1), 121–145 (1977)MathSciNetCrossRefGoogle Scholar
  23. 23.
    Monperrus, M.: A critical review of automatic patch generation learned from human-written patches: essay on the problem statement and the evaluation of automatic software repair. In: Proceedings of the 36th International Conference on Software Engineering, pp. 234–242. ACM (2014)Google Scholar
  24. 24.
    Mottu, J.-M., Simula, S.S., Cadavid, J., Baudry, B.: Discovering model transformation pre-conditions using automatically generated test models. In: 2015 IEEE 26th International Symposium on Software Reliability Engineering (ISSRE), pp. 88–99. IEEE (2015)Google Scholar
  25. 25.
    OMG. Object Constraint Language (OCL) (2014).
  26. 26.
    Reimann, J., Wilke, C., Demuth, B., Muck, M., Aßmann, U.: Tool supported OCL refactoring catalogue. In: Proceedings of the 12th Workshop on OCL and Textual Modelling, Innsbruck, Austria, pp. 7–12, 30 September 2012Google Scholar
  27. 27.
    Rose, L., Guerra, E., De Lara, J., Etien, A., Kolovos, D., Paige, R.: Genericity for model management operations. Softw. Syst. Model. 12(1), 201–219 (2013)CrossRefGoogle Scholar
  28. 28.
    Solar-Lezama, A., Tancau, L., Bodik, R., Seshia, S., Saraswat, V.: Combinatorial sketching for finite programs. ACM Sigplan Not. 41(11), 404–415 (2006)CrossRefGoogle Scholar
  29. 29.
    Tibermacine, C., Sadou, S., Dony, C., Fabresse, L.: Component-based specification of software architecture constraints. In: Proceedings of the 14th International ACM Sigsoft Symposium on Component Based Software Engineering, pp. 31–40. ACM (2011)Google Scholar
  30. 30.
    Varró, D., Bergmann, G., Hegedüs, Á., Horváth, Á., Ráth, I., Ujhelyi, Z.: Road to a reactive and incremental model transformation platform: three generations of the VIATRA framework. Softw. Syst. Model. 15(3), 609–629 (2016)CrossRefGoogle Scholar
  31. 31.
  32. 32.
    Wimmer, M., Perez, S.M., Jouault, F., Cabot, J.: A catalogue of refactorings for model-to-model transformations. J. Object Technol. 11(2), 1–40 (2012)Google Scholar

Copyright information

© Springer International Publishing AG, part of Springer Nature 2018

Authors and Affiliations

  1. 1.Universidad de MurciaMurciaSpain

Personalised recommendations