I have a method that takes three parameters: List<Class1> source
, List<Class2) results
, and DateTime endDate
. I can see why the class coupling is four. However, it jumps to ten when I add this statement:
var warnings = from s in source
join r in results on s.Field1 equals r.Field1 into joined
from j in joined.DefaultIfEmpty( )
where j == null
select string.Format( "{0}{1}", A_CONSTANT, s.Field2 );
My questions:
The six additional classes are possibly:
IEnumerable<string>
- the result of your queryIEnumerable<Class1>
- the left collectionIEnumerable<Class2>
- the right collectionFunc<Class1, int>
- the left part of the join expressionFunc<Class2, int>
- the right part of the join expressionFunc<Class1, Class2, string>
- the projectionIt's also possible that it's counting the Enumerable
class since the query is translated to static extension method calls.
In either case, the code analysis does not seem to ignore transient classes used by Linq (whether it should or not is debatable). My advice is to either ignore it (perhaps manually counting the coupling and noting the difference) or finding a better analysis tool.
Another question would be: does it increase your coupling overall? I suspect that several of these classes are used throughout your app, so it may not make a significant difference on your overall coupling.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With