Ericsson / CodeCompass

CodeCompass is a software comprehension tool for large scale software written in C/C++ and Java
https://codecompass.net
GNU General Public License v3.0
496 stars 96 forks source link

Afferent Coupling at Type Level for C++ #671

Open mcserep opened 7 months ago

mcserep commented 7 months ago

Coupling is metric which can be computed for structural units at different levels (e.g. classes, namespaces, modules). It measures how many other entities an entity depends on; and how many dependants it has.

The Afferent Coupling for a particular type is the number of types that depends directly on it.

High afferent coupling indicates that the concerned types have many responsibilities, while a zero value could indicate unused code.

schaumb commented 7 months ago

Counts:

Remaining questions @mcserep :

mcserep commented 6 months ago

Which user-defined types count? Only those defined in the analyzed code? How did I know whose are defined in the user space?

Types which are defined in files under the project root. (Given with the -i flag for the parser.) Special attention could be required for template types.

What about std::vector or std::unique_ptr? Are these different than A?

If type B uses A, std::vector<A> and std::unique_ptr<A>, then it increases the afferent coupling with 1.
If type B uses std::vector<std::map<A, C>>, then B depends on A and C as well.

What is about MyTemplate<A> and MyTemplate<B> ? Are these different?

This means all 3 types are used.

Probably when we count the classes, the std::decay_t<type> is matter (A, A and A[4] is not different). Is that right?

Type A should be counted here.