UML class diagram object-oriented metrics: algorithms of calculation

. The paper proposes algorithms of the object oriented UML class diagram metrics calculation. Metrics include Average CBO, Average DIT, Average NOC, Average DAC, Average NLM, Average NOM, DAC2, SIZE2, and DSC. The proposed algorithms have become a part of the UML Refactoring tool providing UML class diagram analysis and transformation.


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).
The problem of model refactoring is tightly connected with the MDA approach: model refactoring is less time consuming than code refactoring.In addition, models can help a developer to look at the software system from a perspective view.
In the MDA approach, software models are designed using UML diagrams.UML class diagrams describe main classes, interfaces of the system and the relations between them.
With the software systems of the large size, it becomes harder to analyze UML class diagrams manually.Software tools of the automated UML class diagrams refactoring have been developed: Dearthóir [5], Darwin [6], CODe-Imp [7], Bunch tool [8], UML Refactoring [9], etc.
These tools use a fitness function for the refactoring process.Nowadays a number of studies have investigated several means of the object oriented metrics [10][11][12][13][14].Some of them can be calculated for the UML class diagrams too [15] (see Fig. 1).

Fig. 1. UML class diagram metrics
The aim of this paper is to propose algorithms of several object oriented UML class diagram metrics calculation based on the abstract data structure UML Map [9].
The rest of this paper is organized as follows: First, the UML Map abstract data structure, which stores elements of a UML class diagram in hash maps, is introduced in Section 2. In Section 3, the algorithms of object oriented UML class diagram metrics calculation including Avg.CBO, Avg.DIT, Avg.NOC, Avg.DAC, Avg.NLM, Avg.NOM, DAC2, SIZE2, and DSC [9] are proposed.In addition, the experimental results of applying these algorithms to class diagrams of different size are presented.In Section 4, the role of the proposed algorithms in the UML Refactoring software tool is introduced before concluding in Section 5.With the UML Map, it is possible to calculate metrics, search elements where transformation application is convenient, automatically transform diagrams, etc.

Algorithms of the object-oriented UML class diagram metrics calculation
The Average CBO metric can be calculated as follows:

Fig. 4. Performance of the Average CBO Metric Calculation Algorithm
The Average DIT metric can be calculated as follows:

UML Refactoring tool
The introduced algorithms have become a part of the automated UML class diagram refactoring framework UML Refactoring [9], which can be downloaded from the official site of the project: www.uml-refactoring.ru.
This tool calculates various object-oriented metrics (such as Avg.DIT, Avg.CBO, DAC, SIZE2, etc.) and proposes a list of transformations (Interface Insertion, Façade, Strategy), 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.
The main window of the UML Refactoring tool is shown in Fig. 13.

Conclusions
The proposed UML Map abstract data structure provides convenient UML class diagram analysis and transformation.

Fig. 2 .
Fig. 2. Reduced class diagram of the UML Map abstract data structure The detailed UML class diagram of the classes, providing analysis and transformation of UML class diagrams is shown in Fig. 3.

Fig. 3 .
Fig. 3. UML class diagram of the UML Map classes providing UML class diagram storage, analysis and transformation For example, the complexity of searching a class with the xmi:id = "X" in an XMI text document is evaluated as ), (n O while the complexity of searching in a hash map storing pairs of keys and values {xmi:id, Class} is evaluated as ). 1 ( O Special Translator has been developed to translate an XMI file to the UML Map and from the UML Map to an XMI file.

A
graph depicting the execution time of the algorithm depending on the UML class diagram size is shown in Fig. 5.The value of the execution time was calculated as the average execution time measured during 10000 runs for each UML class diagram size.

Fig. 9 .
Fig. 9. Performance of the Average NOM Metric Calculation Algorithm

Fig. 11 .
Fig. 11.Performance of the Average SIZE2 Metric Calculation AlgorithmThe DSC metric can be calculated as follows:

Fig. 12 .
Fig. 12. Performance of the DSC Metric Calculation Algorithm

Fig. 13 .
Fig. 13.Performance of the DSC Metric Calculation Algorithm The fitness function selection window is shown in Fig. 14.

Fig. 14 .
Fig. 14.Performance of the DSC Metric Calculation Algorithm

UML Map abstract data structure UML Map
abstract data structure provide UML model storage, analysis and transformation.It is based on the hash maps of UML model elements.The reduced UML class diagram of the UML Map abstract data structure is shown in Fig. 2.