以C开头的类名 [英] Class names that start with C

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

问题描述

MFC具有以C开头的所有类名。例如,CFile和CGdiObject。有没有人看到它使用其他地方?有没有微软的官方命名约定指南,建议这种风格?

The MFC has all class names that start with C. For example, CFile and CGdiObject. Has anyone seen it used elsewhere? Is there an official naming convention guide from Microsoft that recommends this style? Did the idea originate with MFC or was it some other project?

推荐答案

在Symbian C ++中使用了一些类似的东西,其中约定是:

Something a bit similar is used in Symbian C++, where the convention is that:

T类是值,例如TChar,TInt32,TDes

T classes are "values", for example TChar, TInt32, TDes

R类是内核(或其他)资源的句柄,例如RFile,RSocket

R classes are handles to kernel (or other) resources, for example RFile, RSocket

M类是mixins,包括接口(被解释为没有函数实现的mixin)。指导原则是多重继承应该涉及最多1个非M类。

M classes are mixins, which includes interfaces (construed as mixins with no function implementations). The guideline is that multiple inheritance should involve at most 1 non-M class.

C类几乎是其他任何东西,并且派生自CBase,它有一些东西以帮助资源处理。

C classes are pretty much everything else, and derive from CBase, which has some stuff in it to help with resource-handling.

HBufC主要用于在Symbian论坛上生成混淆的帖子,并且拥有自己的前缀只是开始。 H代表huh?,或者可能是haw,haw!你没有STL! ; - )

HBufC exists primarily to generate confused posts on Symbian forums, and having its very own prefix is just the start. The H stands for "huh?", or possibly "Haw, haw! You have no STL!" ;-)

这在精神上接近于Apps Hungarian Notation而不是系统匈牙利记法。前缀告诉你关于类的一些内容,你可以在文档中查找,但是你不会知道。 在编程中命名任何东西的整个要点是提供这样的提示和提醒,否则你只需调用你的类Class001,Class002等。

This is close in spirit to Apps Hungarian Notation rather than Systems Hungarian notation. The prefix tells you something about the class which you could look up in the documentation, but which you would not know otherwise. The whole point of naming anything in programming is to provide such hints and reminders, otherwise you'd just call your classes "Class001", "Class002", etc.

系统匈牙利语只是告诉你一个变量的类型,IMO不是非常兴奋,特别是在像C ++这样的语言中,类型往往要么不断重复,要么完全被模板参数隐藏。它的类似命名类型是Java实践中的命名所有接口与I.同样,我不感到非常兴奋这(和标准Java库),但如果你要为每个类定义一个接口,除了在非测试情况下实际用于多态性的接口,那么你需要一些方法来区分两者。

Systems Hungarian just tells you the type of a variable, which IMO is nothing to get very excited about, especially in a language like C++ where types tend to be either repeated constantly or else completely hidden by template parameters. Its analogue when naming types is the Java practice of naming all interfaces with I. Again, I don't get very excited about this (and neither do the standard Java libraries), but if you're going to define an interface for every class, in addition to the interfaces which are actually used for polymorphism in non-test situations, then you need some way to distinguish the two.

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

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