Automated Refactoring of OCL Constraints with Search

Hong Lu1, Shuai Wang1, Tao Yue1,2, Shaukat Ali1, Jan Nygård3

1Simula Research Laboratory, Oslo, Norway; 2Department of Informatics, University of Oslo, Oslo, Norway; 3Cancer Registry of Norway, Oslo, Norway
Contact: {honglu, shuai, tao, shaukat}@simula.no, Jan.Nygard@kreftregisteret.no

Abstract

Object Constraint Language (OCL) constraints are typically used to provide precise semantics to the models developed in the Unified Modeling Language (UML). When there is a need in practice for OCL constraints to evolve regularly, it is essential that they are easy to understand and maintain. For instance, in cancer registries, to ensure quality of cancer data, more than one thousand regularly evolving medical rules are defined, which can be specified using OCL. It is therefore important to ensure the understandability and maintainability of medical rules in OCL. To tackle such a challenge, this paper proposes an automated search-based OCL constraint refactoring approach by defining and applying four semantics-preserving refactoring operators (i.e., Context Change, Swap, Split and Merge) and three OCL quality metrics (Complexity, Coupling and Cohesion) to measure the understandability and maintainability. Notice that semantics- preserving is an inherent property of our approach. We evaluate the proposed approach along with six commonly used multi- objective search algorithms (e.g., Indicator-Based Evolutionary Algorithm (IBEA)) by employing a case study from the Cancer Registry of Norway (CRN) with real cancer data of cancer patients (i.e., 218 cancer messages and 95 cancer cases) and 469 medical rules. Results show: 1) the semantics-preserving property of our approach is correctly implemented; 2) IBEA achieves the best performance among all the search algorithms and 3) the refactoring approach along with IBEA can manage to reduce 40% Complexity and 43% Coupling, and enhance 95% Cohesion, as compared to the original OCL constraint set from CRN.

For implementation:

As mentioned in the paper, all the selected search algorithms and quality indicators are implemented based on jMetal [1].

For the experiment data: Two types of data are made available: 1) We provide the original OCL constraint set that including 469 medical rules and refactored OCL constraint sets produced by each search algorithm. Each algorithm was run with 50 times and all the refactored OCL constraint sets produced by the algorithm are stored in a seperate file; and 2) We provide the data for objective function values, corresponding solutions and time taken by running each algorithm. A file name "Value of Metrics.txt" containing the three metrics for the original constraint set is also included.

Data related with the experiment

Download The data related with the original OCL constraint set and refactored OCL constraint sets produced by each algorithm

Download The data related with objective function values, corresponding solutions and time taken for running each algorithm