-2

匿名类型可以被认为是“设置一次”Object类型,而普通的 oldObject或 Variant 可以设置多次。对象或变体的寿命往往很短,而匿名类型的寿命预计会更长,因此传达意图很重要。

使用匿名类型时,您使用什么命名约定来传达意图?

我搜索了“命名约定”问题,但对于与对象或变体不同的匿名类型,答案仍然难以捉摸。

匈牙利符号就像舞会之夜的一个巨大的鼻子疙瘩,所以那里可能没有什么用处。

既然匿名类型一旦被实例化就不能改变,不应该根据它的意图来命名吗?

4

3 回答 3

2

当我在 Java Swing 应用程序中使用匿名类型时,我以下列方式使用它们:

private ActionListener [actionPerforming]Action = new ActionListener(){ /*Stuff Here*/};

这样就很清楚变量在做什么。

于 2009-04-22T17:54:11.383 回答
0

Well, it may seem somewhat of an oxymoron but shouldn't you use whatever naming convention means the most to you, as the developer? Whatever appeals to you, makes you most comfortable..

Personally, I used to favour Hungarian Notation but I was recently converted to the camelCase (Microsoft?) method by the elegance of it. It's a matter of personal choice, really.

于 2010-02-04T13:41:27.970 回答
0

查看匈牙利符号命名约定。 http://en.wikipedia.org/wiki/Hungarian_notation

nSize : integer (systems) or count (application)
iSize : integer (systems) or index (application)    
bBusy : boolean
chInitial : char
cApples : count of items
dwLightYears : double word (systems)
fBusy : boolean (flag)
fpPrice: floating-point
于 2010-02-04T13:46:33.420 回答