views:

271

answers:

8

Which one is preferable or more clear?

public int FrozenRegionWidth { get; set; }

Or...

public int WidthOfFrozenRegion { get; set; }
+8  A: 

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)?

AndrewS
A: 

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.

Vadim
I think it's question for this community. I don't think this is project specific. The question could have been written as WidthOfBlabla or BlablaWidth?
Hao Wooi Lim
A: 

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.

CodingTales
A: 

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?

Hao Wooi Lim
If you are talking about using Intellisense, is it realistic to expect all of the following conditions to be true: - Developers using your class are completely ignorant of it - The developers do not have any documentation to refer to - The class has so many properties that it is difficult to figure out which is which simply by skimming the Intellisense list - None of the properties have XML comments to describe what they are
Rex M
You do have a point.
Hao Wooi Lim
A: 

Personally, i would prefere

public int FrozenRegionWidth { get; set; }
A: 

I'd would prefer FrozenRegionWidth.

For more informations refer to .NET framework naming guidelines at http://msdn.microsoft.com/en-us/library/ms229012.aspx

munissor
A: 

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.

annakata
A: 

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.

Chris S