2023-05-03 11:06:20 +02:00
|
|
|
== Why is this an issue?
|
|
|
|
|
2020-06-30 12:47:33 +02:00
|
|
|
include::description.adoc[]
|
|
|
|
|
2023-05-25 14:18:12 +02:00
|
|
|
=== Noncompliant code example
|
|
|
|
|
|
|
|
With a threshold of 5:
|
|
|
|
|
|
|
|
[source,text]
|
|
|
|
----
|
|
|
|
class Foo { // Noncompliant - Foo depends on too many classes: T1, T2, T3, T4, T5, T6 and T7
|
|
|
|
T1 a1; // Foo is coupled to T1
|
|
|
|
T2 a2; // Foo is coupled to T2
|
|
|
|
T3 a3; // Foo is coupled to T3
|
|
|
|
|
|
|
|
public T4 compute(T5 a, T6 b) { // Foo is coupled to T4, T5 and T6
|
|
|
|
T7 result = a.getResult(b); // Foo is coupled to T7
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class Bar { // Compliant - Bar depends on 2 classes: T8 and T9
|
|
|
|
T8 a8;
|
|
|
|
T9 a9;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
----
|
|
|
|
|