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:
Can someone explain me how to calculate it?
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:
Can someone explain me how to calculate it?
Copyright © 2021 Jogjafile Inc.

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:
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:
EntryStationhas only attributes of primary types: no couplingUser: no couplingATMis associated withConsortium(shared aggregation) and has aCashierStationattribute: coupling with 2 classesCashierStationhas anEntryStationattribute and aBranchattribute ans is also associated with Branch: coupling with 2 classesConsortiumis associated withATMand hasBranch,EntryStationandUserattributes: coupling with 4 classes !Branchis associated and has aCashierStationattribute. It hasATMandUserattributes: 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:
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
NumAttrandParammetric, but that theNumAttrmetric 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.