[英]Why does Class Coupling jump when I use LINQ?
I have a method that takes three parameters: List<Class1> source
, List<Class2) results
, and DateTime endDate
. 我有一个方法,它有三个参数:
List<Class1> source
, List<Class2) results
和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 query IEnumerable<string>
- 查询的结果 IEnumerable<Class1>
- the left collection IEnumerable<Class1>
- 左集合 IEnumerable<Class2>
- the right collection IEnumerable<Class2>
- 正确的集合 Func<Class1, int>
- the left part of the join expression Func<Class1, int>
- 连接表达式的左侧部分 Func<Class2, int>
- the right part of the join expression Func<Class2, int>
- 连接表达式的右侧部分 Func<Class1, Class2, string>
- the projection Func<Class1, Class2, string>
- 投影 It's also possible that it's counting the Enumerable
class since the query is translated to static extension method calls. 由于查询被转换为静态扩展方法调用,因此它也可能计算
Enumerable
类。
In either case, the code analysis does not seem to ignore transient classes used by Linq (whether it should or not is debatable). 在任何一种情况下,代码分析似乎都不会忽略Linq使用的瞬态类(无论它是否应该是有争议的)。 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.
我怀疑在您的应用程序中使用了其中几个类,因此它可能不会对您的整体耦合产生显着影响。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.