2

I am trying to understand the Direct Class Coupling (DCC). I try to to calculate the DCC metrics for a class diagram but I don't know how the article that I read obtained value 2:

enter image description here

Can someone explain me how to calculate it?

Christophe
  • 68,716
  • 7
  • 72
  • 138
memo
  • 21
  • 1
  • Welcome on SO. Do you have the reference of the article you are reading ? – Christophe Jul 29 '23 at 08:41
  • this is the reference: https://fount.aucegypt.edu/cgi/viewcontent.cgi?article=3320&context=retro_etds – memo Jul 29 '23 at 09:02
  • And thank you for the welcome – memo Jul 29 '23 at 09:12
  • Personally I think those metrics are just glas bowls. Anyhow: https://learn.microsoft.com/en-us/visualstudio/code-quality/code-metrics-class-coupling?view=vs-2022 tells it's a dependency count. _EntryStation_ has 2 association. Thus its metric is 2. – qwerty_so Jul 29 '23 at 09:13
  • I assume you refer to the example on pp. 87. Where is that value _2_ you are concerned with indicated? – qwerty_so Jul 29 '23 at 09:18
  • Nice to see that there are tools that calculate such metrics directly from an UML diagram. After having read the article, and understood that it used the DCC average per class I come to the conclusion that it's probably a bug in the customisation of the tool. – Christophe Jul 29 '23 at 13:26

1 Answers1

0

The Direct Class Coupling metric is a metric that measures the dependency of a class to other classes of the system. The more dependencies with other class, the more difficult it'll get to reuse that class or to maintain it. While I didn't find the original article of Bansiya and Davis in 2002 that defines it, I found its description in other academic papers, as well as in a DDJ article of 1997 in which Bansiya & Davis describe a tool that calculates metrics automatically from source code:

count of the different number of classes that a class is directly related to, including those related by attribute declarations and message passing (parameters) in methods.

Moreover its similarity with CBO (Coupling Between Object classes), in particular regarding inheritance which is not counted in the coupling, and regarding multiple relations between the same classes that are counted only once, lead to the following analysis:

  • EntryStation has only attributes of primary types: no coupling
  • User: no coupling
  • ATM is associated with Consortium (shared aggregation) and has a CashierStation attribute: coupling with 2 classes
  • CashierStation has an EntryStation attribute and a Branch attribute ans is also associated with Branch: coupling with 2 classes
  • Consortium is associated with ATM and has Branch, EntryStation and User attributes: coupling with 4 classes !
  • Branch is associated and has a CashierStation attribute. It has ATM and User attributes: coupling with 3 classes !

So looking at the diagram overall, the maximum coupling is 4. The total number of couplings would be 11. The average per class would be 1.83, not far from 2, but still not 2.

Edit

Following your referenced article, I've removed the list of possible alternative counting of my previous answer.

The article shows DCC which have decimals, which can therefore not be the count of couplings as originally defined. It explains (Table 3.3.) that the formula used to evaluate an UML model is:

Summ(NumAttrandParam) / NumCls 

The second element is the number of classes in the package, according to the metrics definition of the SDMetrics software the author used. This is clearly 6.

The first element, is according to the author an adapted metric calculated with custom code. Considering that the SDMetrics doesn't have a NumAttrandParam metric, but that the NumAttr metric is simply a count of the attributes, I could imaging that there is a bug in this metric: for example if he counted each attribute even if it has the same class, it would compute in total 12 couplings because of the 2 ATM in Branch, which would then result in an average per class of 2.

Christophe
  • 68,716
  • 7
  • 72
  • 138
  • Thanks a lot for your interest and for the comprehensive answer. I needed the following sentence "I could imaging that there is a bug in this metric" – memo Jul 29 '23 at 13:53