Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I manually calculate Efferent Coupling (Ce) for a .Net class?

If I want to manually calculate the efferent coupling of a .Net class should I include types from the CLR in my calculation, or just types I have created?

like image 778
David Osborne Avatar asked Dec 02 '25 02:12

David Osborne


1 Answers

The tool NDepend that calculates the efferent coupling takes account of third-party types used. (Documentation here). Here is a CQLinq code query that shows this fact:

NDepend efferent coupling

Notice that it is possible to recalculate the efferent coupling only for application types used if you wish.

NDepend efferent coupling without third-party

If your goal is to detect if a type has too many responsibilities (which is often the case when a type is using many others types, many means like several dozens) this makes sense to include types from the .NET Fx. For example the usage of types in System.IO or System.Threading clearly indicates a special responsibility for the user type. This is also why for detecting many responsibilities, you could count also the number of namespaces used (including third-party ones)

NDepend efferent coupling, parent namespaces

Disclaimer: I am working in the NDepend team

like image 66
Patrick from NDepend team Avatar answered Dec 04 '25 18:12

Patrick from NDepend team



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!