Skip to main content
Log in

From well-formedness to meaning preservation: model refactoring for almost free

  • Special Section Paper
  • Published:
Software & Systems Modeling Aims and scope Submit manuscript

Abstract

Modelling languages such as the UML specify well-formedness as constraints on models. For the refactoring of a model to be correct, it must take these constraints into account and check that they are still satisfied after the refactoring has been performed—if not, execution of the refactoring must be refused. By replacing constraint checking with constraint solving, we show how the role of constraints can be lifted from permitting or denying a tentative refactoring to computing additional model changes required for the refactoring to be executable. Thus, to the degree that the semantics of a modelling language is specified using constraints, refactorings based on these constraints are guaranteed to be meaning preserving. To be able to exploit constraints available in the form of a language’s well-formedness rules for refactoring, we present a mapping from these rules to the constraint rules required by constraint-based refactoring. Where there are no gaps between well-formedness and (static) semantics of a modelling language, these mappings enable structural refactorings of models at no extra cost; where there are, we identify ways of detecting and filling the gaps.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Fig. 1
Fig. 2
Fig. 3
Fig. 4

Similar content being viewed by others

Notes

  1. For the sake of simplicity, we assume here that all operations of a classifier are defined in the same class diagram. In practice, different operations may be introduced in different class diagrams, showing different views on the model; yet, for a sequence diagram to be checkable for well-formedness, it cannot introduce the required operations itself.

  2. We use the term property here to collectively denote attributes and association ends associated with an object ([10, §7.5.1 and §7.5.3). Conforming to [10], we use the dot notation \(o\).\(p\) to denote the value of a property \(p\) of an object \(o\), where \(o\) may be an object literal or a variable (including another property).

  3. Note that the classifier literal \(C_{\!\textit{Content}}\) is both the owner of the property \(C_{\!\textit{Content}}\).operations and the value of the property \(l_{\!\textit{right}}\) .classifier. This is so because the property classifier has reference semantics, a notion foreign to standard constraint solvers; we will return to this in Sect. 4.3.

  4. NB: It is admissible in UML that not all information that can be specified in a diagram is actually provided by the modeller. For instance, in a sequence diagram the name of a message may be omitted. This intentional underspecification is a feature of modelling rather than a bug of the modelling language; however, deliberately underspecified models are generally inept to identify the semantic underspecification of the language we are searching for.

  5. Note that the metamodel of Fig. 2 is insufficient to detect the underspecification automatically, by means of interpretation—since this metamodel does not provide for the binding of a message to an operation, it cannot be derived that binding is ambiguous.

  6. See [19] for how constraint-based refactorings can be specified formally. As has been pointed out in [22], the difference between the kind of a refactoring and its particular application dissolves when ad hoc refactorings, that is, refactorings which have not been standardized and which can perform arbitrary changes, are considered.

  7. In theory, the constraints can be generated from the constraint rules and the program to be refactored alone. However, in practice this leads to a large number of superfluous constraints (i.e., constraints that are unrelated to the intended refactoring). Therefore, special algorithms have been devised that generate only the constraints required for a specific application of a specific kind of refactoring [19, 21]. These algorithms take the specific application as part of their input.

  8. Cf. the initial remarks of Sect. 2.5 concerning the correctness of refactoring under underspecification.

  9. Arguably, a semantic interpretation that contains a choice (a disjunction) is ambiguous.

References

  1. Ali, S., Iqbal, M.Z., Arcuri, A., Briand, L.: A search-based OCL constraint solver for model-based test data generation. In: Proceedings of QSIC, pp. 41–50 (2011)

  2. Cabot, J., Clarisó, R., Riera, D.: UMLtoCSP: a tool for the formal verification of UML/OCL models using constraint programming. In: Proceedings of ASE, pp. 547–548 (2007)

  3. Correa, A.L., Werner, C.M.L.: Applying refactoring techniques to UML/OCL models. In: Proceedings of UML, pp. 173–187 (2004)

  4. Egyed, A.: Fixing inconsistencies in UML design models. In: Proceedings of ICSE, pp. 292–301 (2007)

  5. Fowler, M.: Refactoring: Improving the Design of Existing Code. Addison-Wesley, New York (1999)

    Google Scholar 

  6. Gheyi, R., Massoni, T., Borba, P.: A rigorous approach for proving model refactorings. In: Proceedings of ASE, pp. 372–375 (2005)

  7. Griswold, W.G.: Program restructuring as an aid to software maintenance. PhD Dissertation, University of Washington (1992)

  8. Moha, N., Mahé, V., Barais, O., Jézéquel, J.M.: Generic model refactorings. In: Proceedings of MoDELS, pp. 628–643 (2009)

  9. OMG Unified Modeling Language Superstructure Version 2.3. www.omg.org/spec/UML/2.3/Superstructure. May 2010

  10. Object Management Group Object Constraint Language Version 2.2. http://www.omg.org/spec/OCL/2.2

  11. Palsberg, J., Schwartzbach, M.I.: Object-Oriented Type Systems. Wiley, New York (1994)

    MATH  Google Scholar 

  12. Philipps, J., Rumpe, B.: Refactoring of programs and specifications. In: Practical Foundations of Business and System Specifications, pp. 281–297. Kluwer, Dordrecht (2003)

  13. Porres, I.: Model refactorings as rule-based update transformations. In: Proceedings of UML, pp. 159–174 (2003)

  14. Pretschner, A., Prenninger, W.: Computing refactorings of state machines. Softw. Syst. Model. 6(4), 381–399 (2007)

    Article  Google Scholar 

  15. Reimann, J., Seifert, M., Aßmann, U.: Role-based generic model refactoring. In: Proceedings of MoDELS, vol. 2, pp. 78–92 (2010)

  16. Russell, S., Norvel, P.: Norvel Artificial Intelligence: A Modern Approach, 2nd edn. Prentice Hall (2003)

  17. Schäfer, M.: Specification, implementation and verification of refactorings. PhD Thesis, Oxford University Computing Laboratory (2010)

  18. Steimann, F., Thies, A.: From public to private to absent: refactoring Java programs under constrained accessibility. In: Proceedings of ECOOP, pp. 419–443 (2009)

  19. Steimann, F., Kollee, C., von Pilgrim, J.: A refactoring constraint language and its application to Eiffel. In: Proceedings of ECOOP, pp. 255–280 (2011)

  20. Steimann, F.: Contraint-based model refactoring. In: Proceedings of MoDELS, pp. 440–454 (2011)

  21. Steimann, F., von Pilgrim, J.: Constraint-based refactoring with foresight. In: Proceedings of ECOOP, pp. 535–559 (2012)

  22. Steimann, F., von Pilgrim, J.: Refactorings without names. In: Proceedings of ASE, pp. 290–293 (2012)

  23. Sunyé, G., Pollet, D., Le Traon, Y., Jézéquel, J.M.: Refactoring UML Models. In: Proceedings of UML, pp. 134–148 (2001)

  24. Tip, F., Kiezun, A., Bäumer, D.: Refactoring for generalization using type constraints. In: Proceedings of OOPSLA, pp. 13–26 (2003)

  25. Tip, F., Fuhrer, R.M., Kiezun, A., Ernst, M.D., Balaban, I., De Sutter, B.: Refactoring using type constraints. ACM Trans. Program. Lang. Syst. 33(3), 9 (2011)

    Google Scholar 

  26. Xiong, Y., Hu, Z., Zhao, H., Song, H., Takeichi, M., Mei, H.: Supporting automatic model inconsistency fixing. In: Proceedings of ESEC/SIGSOFT FSE, pp. 315–324 (2009)

Download references

Acknowledgments

The work described in this article has been supported by the Deutsche Forschungsgemeinschaft (DFG) under grant STE 906/4-1. The author thanks Thomas Kühne for his comments on an earlier version of this article.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Friedrich Steimann.

Additional information

Communicated by Prof. Tony Clark and Prof. Jon Whittle.

Rights and permissions

Reprints and permissions

About this article

Cite this article

Steimann, F. From well-formedness to meaning preservation: model refactoring for almost free. Softw Syst Model 14, 307–320 (2015). https://doi.org/10.1007/s10270-013-0314-z

Download citation

  • Received:

  • Revised:

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s10270-013-0314-z

Keywords

Navigation