对于抽象类的命名约定 [英] Naming conventions for abstract classes

查看:1225
本文介绍了对于抽象类的命名约定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我清楚地记得,在同一时间,推动微软的方针是基地后缀添加到一个抽象类,以避免的事实,它是抽象的。因此,我们有类,如 System.Web.Hosting.VirtualFileBase System.Configuration.ConfigurationValidatorBase System.Windows.Forms.ButtonBase ,当然了, System.Collections.CollectionBase

I distinctly remember that, at one time, the guideline pushed by Microsoft was to add the "Base" suffix to an abstract class to obviate the fact that it was abstract. Hence, we have classes like System.Web.Hosting.VirtualFileBase, System.Configuration.ConfigurationValidatorBase, System.Windows.Forms.ButtonBase, and, of course, System.Collections.CollectionBase.

但我注意到最近的,有很多抽象类的框架似乎并没有被这一规则。例如,下面的类都是抽象的,但不遵守这个约定:

But I've noticed that, of late, a lot of abstract classes in the Framework don't seem to be following this convention. For example, the following classes are all abstract but don't follow this convention:

  • System.DirectoryServices.ActiveDirectory.DirectoryServer

System.Configuration.ConfigurationElement

System.Drawing.Brush的

System.Windows.Forms.CommonDialog

而这正是我可以在几秒钟内鼓了起来。于是我就找了一下官方文档说的话,以确保我是不是疯了。我发现类,结构的名称和接口的MSDN上的的设计准则类库开发。奇怪的是,我能找到没有提及的方针,以基地添加到一个抽象类的名称的末尾。而这些准则将不再适用于Framework 1.1版。

And that's just what I could drum up in a few seconds. So I went looking up what the official documentation had to say, to make sure I wasn't crazy. I found the Names of Classes, Structs, and Interfaces on MSDN at Design Guidelines for Developing Class Libraries. Oddly, I can find no mention of the guideline to add "Base" to the end of an abstract class's name. And the guidelines are no longer available for version 1.1 of the Framework.

所以,我会失去它?难道这个方针永远存在吗?它是否只是被抛弃不语?我已经在过去两年没有建立长期的类名全部由我自己?

So, am I losing it? Did this guideline ever exist? Has it just been abandoned without a word? Have I been creating long class names all by myself for the last two years for nothing?

有人把我骨头这里。

更新 我没疯。该指引存在。 克日什托夫·Cwalina 2005年抱怨一下吧

Update I'm not crazy. The guideline existed. Krzysztof Cwalina gripes about it in 2005.

推荐答案

框架设计准则 p 174个国家

不要命名基类与基地后缀如果类是旨在用于公共的API。

Avoid naming base classes with a "Base" suffix if the class is intended for use in public APIs.

另外:<一href="http://blogs.msdn.com/kcwalina/archive/2005/12/16/BaseSuffix.aspx">http://blogs.msdn.com/kcwalina/archive/2005/12/16/BaseSuffix.aspx

这篇关于对于抽象类的命名约定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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