calculating coupling and cohesion metrics from XML class diagrm

173 views Asked by At

I am trying to create a project to provide decision making support for class responsibility assignment problem using particle swarm optimization. A fitness function is derived considering various parameters like coupling and cohesion and particle swarm optimization is to be carried out. The input to the program will be an UML class diagram in XML format. How do i calculate the following parameters from the UML class diagram in XML format :

MAC(c) - method-attribute coupling between class c and other classes – Total number of interactions between methods of one class (c) and the attributes of other classes in the same class diagram MMC(c) - method-method coupling between class c and other classes– Total number of interactions between methods of a class (c) and methods of other classes in the same class diagram MGC(c) method-generalization coupling – This is applicable only in those class diagrams where generalization is applied.

RCI(c) ratio of cohesive interactions of class c : RCI(c) = |CI(c)| / |CImax(c)|.

CImax(c) is the maximum possible cohesive interactions in a class c. CI(c) is the number of existing cohesive interactions in a class c.

TCC(c) tight class cohesion - is the pairs of methods, m1 and m2, of a class c∈C with common usage.

DMA (m,a) direct method–attribute dependency between method m and attribute a.

DMM (m1,m) direct method–method dependency between m1 and m2 .

How do i calculate these parameters from the UML class diagram in XML format?

1

There are 1 answers

0
Pétur Ingi Egilsson On

You need to figure out how to deserialise that file into an object representation, one against which you can write an algorithm to do your things.

It is hard to provide help without more information. The file you have, is it an XMI file? You can answer this by opening it up and searching for xmlns:xmi="http://www.omg.org/XMI"; if found, then yes. Is the file an instance of Ecore? You can answer this by searching for ecore:; if found, then yes.

If the file is an XMI representation of a class diagram, and an instance of Ecore then you must open it with Eclipse Modeling Tools. If you manage to open it that way, then your next step would be to familiarise yourself with the Eclipse Modeling Framework (EMF) before writing algorithms which can traverse the class diagram as if it was any other graph-like data structure.

I am aware that my answer is a long shot; even if wrong, I would prefer to keep it here for others to strumble upon, namely those which are trying to open XML representations of class diagrams.