当您升级到 C# 3.0 / VS2008 后,您的编码标准文档发生了怎样的变化?
我们正在将项目从 C# 2.0 / VS2005 升级到 C# 3.0 / VS2008。 作为升级的一部分,我们将在编码标准文档中添加一些项目。
从 C# 2.0 / VS2005 升级到 C# 3.0 / VS2008 时,您将如何(或曾经)更改编码标准文档?
We are in the process of upgrading our projects from C# 2.0 / VS2005 to C# 3.0 / VS2008. As part of the upgrade, we are adding some items to our coding standards document.
How would (or did) you change your coding standards document when upgrading from C# 2.0 / VS2005 to C# 3.0 / VS2008?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您可以/应该提供以下方面的建议:
var
)最后两个会引起一些争议,特别是
var
如果您的约定给出了任何设计指南,我会这样做。建议您还建议程序员考虑使用委托进行专门化,以前他们可能使用继承或接口。排序就是一个很好的例子 - 使用投影来指定排序顺序比编写更容易(并且更具可读性)。
IComparer
的实现。You could/should give advice about:
var
)The last two of these cause some controversy, particularly
var
.If your conventions give any design guidelines, I'd suggest that you also advise programmers to consider using delegates for specialisation where previously they might have used inheritance or interfaces. A good example of this is sorting - it's easier (and more readable) to use a projection to specify a sort order than to write an implementation of
IComparer<T>
.升级恰逢新项目,因此当我们搬家时,我们开始使用 StyleCop 和 FxCop 等工具,这改变了我们的编码标准。 它还可以轻松地强制执行它们:o)
The updgrade coincided with a new project, so when we moved we started using tools like StyleCop and FxCop which altered our coding standards. Also it handily enforces them too :o)
尽管您可能需要查看围绕新功能的编码标准,例如 LINQ 表达式、布局、Lambda 与查询语法,但本身不应因升级而发生任何变化。
Nothing should change per se due to the upgrade, though you may need to look at coding standards around new features, such as LINQ expressions, layout, Lambda versus query syntax.
我个人最讨厌的是在“可能”的地方使用
var
。“可能”当前被定义为以下情况之一,主要是按照整齐度递减的顺序:
明显,有助于 DRY:
受保护,只要它编译,我不在乎:
复杂泛型和几乎任何 LINQ 结果:
My personal pet peeve is the usage of
var
wherever "possible"."Possible" being currently defined as one of the following cases, mostly in order of decreasing neatness:
Obvious, helping DRY:
Guarded, I don't care as long as it compiles:
Complex Generics and almost any LINQ result:
我对 2008 年新功能的标准:
My standards for new features for 2008: