建议为接口命名ContractClassFor辅助类? [英] Recommendation for naming of ContractClassFor helper classes for interfaces?

查看:79
本文介绍了建议为接口命名ContractClassFor辅助类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

'ContractClassFor'辅助类的推荐命名约定是什么?

What is recommended naming convention for 'ContractClassFor' helper classes ?

2.9中的示例使用以下格式:

The sample in 2.9 uses the format:

抽象类I< interface-name>合同

abstract class I<interface-name>Contract

第4.1节使用格式:

类ContractFor< interface-name>  

class ContractFor<interface-name>  

与代码合同一起提供的大多数标准程序集似乎都使用2.9格式。这种格式会生成fxcop / stylecop警告,因为以"I"开头的名称是为接口类型而不是抽象类保留的。

Most of the standard assemblies that ship with code contract seem to use the 2.9 format. This format generates however fxcop/stylecop warnings as names starting with 'I' are reserved for interface types and not abstract classes.

 

  ;

 

 

推荐答案

在书中" C#in Depth,2nd Edition "那里有"抽象类{InterfaceName}合同"在" Cuts 4.0 in Nutshell " "sealed class ContractFor {InterfaceName}"使用。

In the book "C# in Depth, 2nd Edition" there "abstract class {InterfaceName}Contracts" convention is used (I am leaning towards this one), in the book "C# 4.0 in Nutshell" "sealed class ContractFor{InterfaceName}" is used.

由于此类永远不会被实例化,因此将其标记为抽象是个好主意,默认情况下使其符合StyleCop标准对我来说也是合理的。

Since this class is never gonna be instantiated then marking it abstract is good idea, making it StyleCop compliant by default does also sound reasonable for me.

BTW,您使用哪个版本的StyleCope?我使用v4.4.0并没有抱怨像"抽象类IPaymentServiceContracts"这样的类......

BTW, which version of StyleCope do you use? I use v4.4.0 and it doesn't complain about classes like "abstract class IPaymentServiceContracts"...


这篇关于建议为接口命名ContractClassFor辅助类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆