Algorithms of the UML Class Diagram Analysis and Their Effectiveness: Strategy and Interface Insertion Transformations

. A number of studies have investigated different means of the software refactoring. The question is whether there are any effective methods that could provide automated refactoring of the architecture on the design stage with no source code available yet. With the aim of evaluating this possibility, the algorithms of the UML class diagrams analysis were proposed. In addition, the computational experiment was conducted to evaluate the algorithm s’ performance depending on the initial diagram size.


Introduction
Model-Driven Architecture (MDA) approach [1], which was developed by the Object-Management Group (OMG), introduces a new software development paradigm.This paradigm proposes a design process, which starts with the creation of the PIM (Platform Independent Model).Then the PIM is automatically transformed into the PSM (Platform Specific Model).
MDA approach sets out a new research agenda of creating mathematical methods and software tools of model creation, transformation, storage and interchange.
One of the possible research challenges for MDA is the problem of model refactoring.The question is whether there are any effective methods that could provide automated refactoring of the architecture on the design stage with no source code available yet.
A number of studies have investigated different means of the model refactoring.There are two main approaches introduced by researchers.
The first one is based on the SBSE methods, which include GA, Simulated annealing, Swarm intelligence algorithms, etc.An algorithm receives a UML diagram and a fitness function as an input and gives a result diagram as an output [5][6][7][8][9][10].
The problem is that the result, maximizing the fitness function, can be unsatisfactory for the software designer.This can be solved by the interaction with the user on each step of the algorithm [11].
That is why the second approach is connected with the developing frameworks of automated model refactoring, where the main role is given to the software designer.Framework analyses the model and gives recommendations for the refactoring aimed at the maximizing the fitness function, for example.
Software tools based on the second approach include AchE [15], UML Refactoring tool [16], etc.
In addition, various methods of UML class diagram transformation has been developed.The first one is a deterministic algorithm of transformation.However, the disadvantage of this approach is the lack of modifiability: the user cannot add new transformations to the database.
The second approach is usage of XML transformation facilities: XQuery [17] and XLST [18], for example.UML model should be exported to the XMI format, transformed and then imported from the XMI.The disadvantage is connected with the difficultness of understanding the transformations.
Nowadays the QVT (Query/View/Transformation) standard [19] has been developed by OMG.It defines a set of languages for model transformation.It gives the possibility of developing tools, which could allow users to add new transformation rules to the database.
The aim of this paper is to propose algorithms of UML class diagram analysis, which suggest Strategy and Interface transformations in order to minimize/maximize fitness function value.
The rest of this paper is organized as follows: First, the problem of the automated UML class diagram refactoring is formulated in Section 2. Then the UML Map abstract data structure, which stores elements of a UML class diagram in hash maps, is introduced in Section 3. In Section 4, the Strategy transformation analysis algorithm is proposed.In addition, the experimental results of applying this algorithm to class diagrams of different size are presented.After that, in Section 5 the Interface transformation analysis algorithm is proposed including the experimental results of applying it to class diagrams.In Section 6, the role of the proposed algorithms in the UML Refactoring Tool is introduced before concluding in Section 7.

The problem of the automated UML class diagram refactoring
UML class diagram transformation t can be described as the following mapping function: diagram attained as a result of applying the transformation t to the diagram d .
Then the problem of the diagram refactoring can be formulated as searching such a set of pairs }, , { E t that: (2) To be able to conduct the automated UML class diagram refactoring it is important to do the following: 1) formalize the semantics of UML class diagrams, which give an opportunity to check whether transformations keep the invariance of the semantic value; 2) formulate a refactoring criteriafitness function ( ); Secondly, the way of searching parts of the diagram to be transformed depends on the transformation type: there is no general-purpose algorithm.

UML Map abstract data structure
To allow analysis and transformation of UML class diagrams the UML Map abstract data structure has been developed.It stores hash maps of the diagram's classes, interfaces and relations (see Fig. 1) to make diagram processing faster.
For example, the complexity of searching a class with the xmi:id = "X" in an XMI text document is evaluated as With the UML Map, it is possible to calculate metrics, search elements where transformation application is convenient, automatically transform diagrams, etc.

Strategy transformation analysis algorithm
The Strategy transformation means the encapsulation of several algorithms to provide their interchangeability (see Fig. 2 and Fig. 3).

Fig. 2. Preconditions for the application of the Strategy transformation
Algorithm of searching sets of diagram elements E on which the Strategy transformation can be conducted can be described as follows: 1.For each class from the diagram d find those that have inheritors and add them to the hash map <Class, List<Class>> .,...},...} , { , { 1 For each class from the 1 l check whether its inheritors implement any interfaces.If yesadd them to the hash map<Class,List<Class>> .,...},...} , { , { 2 For each class from 2 l calculate ∆f(d).If ∆f(d)<0 - add to the list 3 l = {parent_id, {child_classes_ids}, {interfaces_ids}}.

Fig. 3. The result of the Strategy transformation
For the abstract data structure UML Map, which stores hash maps of diagram classes, interfaces and relations, the algorithm can be described as follows:

Interface transformation analysis algorithm
The Interface insertion transformation involves the creation of an additional level between the classes, which realize a set of methods , M and the classes, which invoke these methods using dependency relations i r .Algorithm of searching sets of diagram elements E on which the Interface transformation can be conducted can be described for the abstract data structure UML Map as follows: 1. Find all classes , d c i which do not implement any interfaces and add them to .' d f .
For the abstract data structure UML Map the algorithm can be described as follows:

UML Refactoring tool
The introduced algorithms have become a part of the automated UML class diagram refactoring framework UML Refactoring Tool [16].This tool allows analyzing UML class diagrams: it calculates various object-oriented metrics (such as Avg.DIT, Avg.CBO [20], DAC, SIZE2 [21], etc.) and proposes a list of transformations, which minimize a fitness function value.In addition, the tool applies the chosen transformation to the diagram.Framework can import/export projects from/to the XMI format.

Conclusions
The proposed UML Map abstract data structure makes it possible to analyze and transform UML class diagrams more convenient than in the XMI format.
The proposed algorithms of UML class diagram analysis allow searching elements of a UML class diagram, on which Strategy and Interface transformation can be applied in order to maximize/minimize fitness function value.
Time performance of the introduced algorithms has been evaluated with the help of the computational experiments.For both of them time performance evaluation is ). (n O

f 3 )
define a list of semantically equivalent transformations, which can be automatically performed by the refactoring algorithm.The problem of the automated UML class diagram refactoring is connected with several difficulties.First, it is hard to formulate a fitness function.Recent advances in UML class diagram quality evaluation provide a wide range of metrics [20-24].However, it is hard to interpret most of these metrics.Scientists have conducted experiments aimed at evaluating the influence of different metrics (CBO, DIT or NOC [20], for example) on the level of the quality criteria [25-27].So far, the results of these investigations sometimes are contradictory.In addition, the ways of measuring such quality criteria as the maintainability and understandability stay subjective.

Fig. 1 .
Fig. 1.Reduced class diagram of the UML Map abstract data structure Special Translator has been developed to translate an XMI file to the UML Map and from the UML Map to an XMI file.With the UML Map, it is possible to calculate metrics, search elements where transformation application is convenient, automatically transform diagrams, etc.

Fig. 4 .
Fig. 4. Performance of the Strategy transformation analysis algorithm

1 l 2 .
Find among these classes i c those that have dependency relations of the kind: