这使得我们的变量short n sweet。 你不能继续写长句子作为变量名。 在这里您正在创建一个自动属性。 请记住这一点。 它更像是一个变量。
FrozenRegionWidth is what is used everywhere. You just can't use
NameOfCustomer
instead of
CustomerName
This makes our variable short n sweet. You can't go on writing long sentences as variable names. And here you're creating an autoproperty. Remember that. It's more like a variable.
You are trying to look for the frozen region's width, but let say that you're not sure that it's called frozen region. Maybesome people call frozen region, another call it RegionThatIsFrozen (I know, lame example) or what ever: in that case, wouldn't it be easier for the programmer to type WidthOf and waits for the autocomplete to kicks in and choose the right one?
I would favour whichever form proffers the more generic information first in the name.
That is to say, I want it so that when I'm looking at a the member list in intellisense they're grouped according to how I want to find them. If "FrozenRegion" is what's important to me than I want to name the related properties FrozenRegionWidth, FrozenRegionFoo, FrozenRegionBar. If I'm looking at "Width" I want WidthFrozenRegion, WidthFoo, WidthBar.
So it depends on your usage, but name from most generic to most specific.
发布评论
评论(8)
我会说 FrozenRegionWidth,否则你最终会得到一大堆以“WidthOf...”开头的属性。
话虽如此,你不应该有像 FrozenRegion.Width 这样的东西吗(我寻找 FrozenRegionWidth 而不是 WidthOfFrozenRegion 的另一个原因)?
I'd say FrozenRegionWidth, otherwise you'll end up with a whole bunch of properties starting with 'WidthOf..'.
Having said that, shouldn't you have something like FrozenRegion.Width (another reason why I'd look for FrozenRegionWidth over WidthOfFrozenRegion)?
我更喜欢 FrozenRegionWidth。
有关详细信息,请参阅 .NET Framework 命名指南,网址为 http://msdn.microsoft .com/en-us/library/ms229012.aspx
I'd would prefer FrozenRegionWidth.
For more informations refer to .NET framework naming guidelines at http://msdn.microsoft.com/en-us/library/ms229012.aspx
我不确定这是否是这个社区的问题。 我相信这一定是您团队的一个问题。
如果我只是团队中的开发人员并且必须选择一个名称,我将创建一个具有 Width 属性的 FrozenRegion 类。
I'm not sure if it's a question for this community. I believe it must be a question for your team.
If I was only developer on a team and I have to choose a name, I would create a FrozenRegion class with Width property.
FrozenRegionWidth 是随处使用的。 你只是不能使用
而不是
这使得我们的变量short n sweet。 你不能继续写长句子作为变量名。
在这里您正在创建一个自动属性。 请记住这一点。 它更像是一个变量。
FrozenRegionWidth is what is used everywhere. You just can't use
instead of
This makes our variable short n sweet. You can't go on writing long sentences as variable names.
And here you're creating an autoproperty. Remember that. It's more like a variable.
但是,请考虑以下场景:
您正在尝试查找冻结区域的宽度,但假设您不确定它是否称为冻结区域。 也许有些人称之为冻结区域,另一个人称之为 RegionThatIsFrozen (我知道,蹩脚的例子)或其他什么:在这种情况下,程序员输入 WidthOf 并等待自动完成启动并选择正确的区域不是更容易吗?
But, consider the following scenario:
You are trying to look for the frozen region's width, but let say that you're not sure that it's called frozen region. Maybesome people call frozen region, another call it RegionThatIsFrozen (I know, lame example) or what ever: in that case, wouldn't it be easier for the programmer to type WidthOf and waits for the autocomplete to kicks in and choose the right one?
就我个人而言,我更喜欢
Personally, i would prefere
我赞成哪种形式在名称中首先提供更通用的信息。
也就是说,我希望当我在智能感知中查看成员列表时,它们会根据我想要的查找方式进行分组。 如果“FrozenRegion”对我来说很重要,那么我想将相关属性命名为 FrozenRegionWidth、FrozenRegionFoo、FrozenRegionBar。 如果我查看“Width”,我想要 WidthFrozenRegion、WidthFoo、WidthBar。
因此,这取决于您的用法,但名称从最通用到最具体。
I would favour whichever form proffers the more generic information first in the name.
That is to say, I want it so that when I'm looking at a the member list in intellisense they're grouped according to how I want to find them. If "FrozenRegion" is what's important to me than I want to name the related properties FrozenRegionWidth, FrozenRegionFoo, FrozenRegionBar. If I'm looking at "Width" I want WidthFrozenRegion, WidthFoo, WidthBar.
So it depends on your usage, but name from most generic to most specific.
这个问题我以类似的方式问过可能有帮助,也可能没有帮助,它有关于名词选择的指标。
为了与 .NET BCL 命名约定保持一致,我将使用 FrozenRegionWidth。 包含介词的情况并不常见。
如上所述,FrozenWidth 看起来像是结构/值类型的主要候选者。
This question I asked on a similar vein may or may not help, it has indicators about noun choice.
To keep inline with the .NET BCL naming conventions I would use FrozenRegionWidth. It's unusual to include prepositions.
As mentioned above, FrozenWidth looks like a prime candidate for a struct/value type.