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

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

问题描述

我清楚地记得,有一次,Microsoft 推动的指导方针是添加Base"抽象类的后缀,以消除它是抽象的事实.因此,我们有类似 System.Web.Hosting.VirtualFileBaseSystem.Configuration.ConfigurationValidatorBaseSystem.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 上找到了类、结构和接口的名称开发类库的设计指南.奇怪的是,我找不到添加Base"的指南.到抽象类名称的末尾.并且这些指南不再适用于框架的 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?

有人向我扔骨头.

更新我没疯.该指南存在.Krzysztof Cwalina 抱怨2005 年.

推荐答案

框架设计指南 p 174 状态:

In Framework Design Guidelines p 174 states:

避免如果类旨在用于公共 API 中,则使用Base"后缀命名基类.

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

另外:http://blogs.msdn.com/kcwalina/archive/2005/12/16/BaseSuffix.aspx

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

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