tags:

views:

84

answers:

4

I have a lot developed in .NET windows forms and they are each named whatever they are with no prefixes. However, I often find myself needing to declare another class that contains the column names that the form uses.

For instance, I have a class called Address, which is a form for the maintenance of addresses. However, I also need a class that I'd like to also call Address that basically just contains the declarations of Name and Address fields. I am looking for a good naming convention to differentiate between the two (the class definition vs. the form).

+7  A: 

Maybe this?

class Address { }
class AddressForm { }
Andrew Hare
+3  A: 

Use Namespaces.

So your form might be in the namespace

YourCompanyName.UI.WinForms.Address

Your value object might be

YourCompanyName.Business.Values.Address

Then you can just use the full namespace to reference them.

David Basarab
That could get very confusing very fast.
Andrew Hare
@Andrew Hare: True, but he wanted Address for both the form name and the value object, the only way to it is with Namespaces. I would prefer your method of AddressForm and Address.
David Basarab
+8  A: 

The normal convention for Windows Forms is to suffix the names of form classes with Form. So, your class for address should be called just Address (because, after all, it is an address), but the form that is used to edit addresses should be AddressForm (or AddressListForm, or AddressEditorForm, etc - depends on what exactly it does).

Pavel Minaev
+1 for Hungarian notation on GUI elements.
ParmesanCodice
It's not Hungarian notation - Hungarian is the use of abbreviated prefixes.
Pavel Minaev
The SharpDevelop C# Coding Style Guide (http://www.icsharpcode.net/TechNotes/) refers to this as Hungarian notation:"8.2. Naming Guidelines Hungarian notation is a defined set of pre and postfixes which are applied to names to reflect the type of the variable. This style of naming was widely used"Wikipedia only makes reference to a prefix. Now whether or not it's a post or prefix really makes no difference, it the *name* implies the *type*, it's Hungarian notation.
ParmesanCodice
It could be argued that the name in this case does not implies the type, but rather the functionality. It just so happens that these two coincide (which should come as no surprise in OO, since a class is an abstraction specifically to capture that). Otherwise, we could get to the point where `Foo foo = new Foo()` would be considered Hungarian notation...
Pavel Minaev
+1  A: 

I suggest Address and AddressForm (or AddressEditor or something like that), too. Naming the form Address seems plain wrong to me - the class does not represent an address but a form to view or manipulate addresses.

Daniel Brückner