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.
Similar content being viewed by others
Notes
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.
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).
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.
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.
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.
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.
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.
Cf. the initial remarks of Sect. 2.5 concerning the correctness of refactoring under underspecification.
Arguably, a semantic interpretation that contains a choice (a disjunction) is ambiguous.
References
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)
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)
Correa, A.L., Werner, C.M.L.: Applying refactoring techniques to UML/OCL models. In: Proceedings of UML, pp. 173–187 (2004)
Egyed, A.: Fixing inconsistencies in UML design models. In: Proceedings of ICSE, pp. 292–301 (2007)
Fowler, M.: Refactoring: Improving the Design of Existing Code. Addison-Wesley, New York (1999)
Gheyi, R., Massoni, T., Borba, P.: A rigorous approach for proving model refactorings. In: Proceedings of ASE, pp. 372–375 (2005)
Griswold, W.G.: Program restructuring as an aid to software maintenance. PhD Dissertation, University of Washington (1992)
Moha, N., Mahé, V., Barais, O., Jézéquel, J.M.: Generic model refactorings. In: Proceedings of MoDELS, pp. 628–643 (2009)
OMG Unified Modeling Language Superstructure Version 2.3. www.omg.org/spec/UML/2.3/Superstructure. May 2010
Object Management Group Object Constraint Language Version 2.2. http://www.omg.org/spec/OCL/2.2
Palsberg, J., Schwartzbach, M.I.: Object-Oriented Type Systems. Wiley, New York (1994)
Philipps, J., Rumpe, B.: Refactoring of programs and specifications. In: Practical Foundations of Business and System Specifications, pp. 281–297. Kluwer, Dordrecht (2003)
Porres, I.: Model refactorings as rule-based update transformations. In: Proceedings of UML, pp. 159–174 (2003)
Pretschner, A., Prenninger, W.: Computing refactorings of state machines. Softw. Syst. Model. 6(4), 381–399 (2007)
Reimann, J., Seifert, M., Aßmann, U.: Role-based generic model refactoring. In: Proceedings of MoDELS, vol. 2, pp. 78–92 (2010)
Russell, S., Norvel, P.: Norvel Artificial Intelligence: A Modern Approach, 2nd edn. Prentice Hall (2003)
Schäfer, M.: Specification, implementation and verification of refactorings. PhD Thesis, Oxford University Computing Laboratory (2010)
Steimann, F., Thies, A.: From public to private to absent: refactoring Java programs under constrained accessibility. In: Proceedings of ECOOP, pp. 419–443 (2009)
Steimann, F., Kollee, C., von Pilgrim, J.: A refactoring constraint language and its application to Eiffel. In: Proceedings of ECOOP, pp. 255–280 (2011)
Steimann, F.: Contraint-based model refactoring. In: Proceedings of MoDELS, pp. 440–454 (2011)
Steimann, F., von Pilgrim, J.: Constraint-based refactoring with foresight. In: Proceedings of ECOOP, pp. 535–559 (2012)
Steimann, F., von Pilgrim, J.: Refactorings without names. In: Proceedings of ASE, pp. 290–293 (2012)
Sunyé, G., Pollet, D., Le Traon, Y., Jézéquel, J.M.: Refactoring UML Models. In: Proceedings of UML, pp. 134–148 (2001)
Tip, F., Kiezun, A., Bäumer, D.: Refactoring for generalization using type constraints. In: Proceedings of OOPSLA, pp. 13–26 (2003)
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)
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)
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
Corresponding author
Additional information
Communicated by Prof. Tony Clark and Prof. Jon Whittle.
Rights 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
Received:
Revised:
Accepted:
Published:
Issue Date:
DOI: https://doi.org/10.1007/s10270-013-0314-z