Hungarian Notation Vs. Pascal Notation

  • Thread starter Thread starter Grey Squirrel
  • Start date Start date
G

Grey Squirrel

On wednesday my company will have an open ended discussion whether to
standardize hungarian notation or pascal/cammel case notation. We'd
love to recieve some feedback on what other people are using out there
and why. Thanks!
 
On wednesday my company will have an open ended discussion whether to
standardize hungarian notation or pascal/cammel case notation. We'd
love to recieve some feedback on what other people are using out there
and why. Thanks!

We use pascal and cammel case. Not only because it is the standard
coding convention for .NET as seen in

* http://msdn2.microsoft.com/en-us/library/ms229043.aspx
* http://msdn2.microsoft.com/en-us/library/ms229045.aspx

--- from coding standards on MSDN ---
Do not use abbreviations or contractions as parts of identifier names.
For example, use OnButtonClick rather than OnBtnClick.
------

In addition we stay way from Hungarian notation because I encourage my
developers to take a more object oriented approach to their naming by
naming things by functional group names. Such as

LoginName
LoginPassword
LoginGoToLocationList
LoginSendButton

Instead of the Hungarian way which scatters the names all over the
list like:

txtName
txtPassword
ddlLocation
btnSend

In addition another benefit of not using Hungarian is the ability to
be more flexible and agile when coding.

If you decide all Lists are going to end with the postfix "List" for
drop down, combo boxes, and everything in between. It is a lot easier
to adjust the interface if somebody wants to go from a combo box to a
drop down list.

SomethingList

However if you use Hungarian you have to rename all your variables to
go from a drop down list to a combo box, if you still want to maintain
your naming convention, which is the original reason why you are
having this meeting.

ddlSomething
cmbSomething

Hope this helps.
 
hi Nick,
In addition we stay way from Hungarian notation because I encourage my
developers to take a more object oriented approach to their naming by
naming things by functional group names. Such as

LoginName
LoginPassword
Relying on IntelliSense, ok.
LoginGoToLocationList
LoginSendButton
Even this is not Hungarian, you incorporate the object type (class) in
its name. This is imho the main point in such discussions:

Use the class name as a part of the object name? How to incorporate it?

Using OO style names, i'd prefer it Java style:

http://java.sun.com/docs/codeconv/html/CodeConventions.doc8.html

Otherwise i'd prefer a Hungarian-style notation, as i'm used to do many
steps manually, where a clean alpha-sorted list of objects is more
useful than a OO-list.


mfG
--> stefan <--
 
Relying on IntelliSense, ok.

Well just having LoginSend or LoginGoToLocation is just a style
thing. The point of the response was to demonstrate the prefix not
the postfix, because Hungarian notation primarily deals with prefix.

Honestly I don't care what my developers postfix their variables with,
they just need to keep the objects logically grouped. Because
Hungarian notation and the notion about having all the like types
together breaks down at or around 10 objects of the same type. See my
response below for more information.
Otherwise i'd prefer a Hungarian-style notation, as i'm used to do many
steps manually, where a clean alpha-sorted list of objects is more
useful than a OO-list.

Well the point of the OO list is that everything is logically grouped
together using alpha-sorted lists.

At least the ease of finding something by type is the reason Hungarian
notation people always give me. But the only way to test if something
really works is to take it to the extreme. What if you page had 10
groups with with 10 text boxes in each group and 1 button in each
group. Wouldn't it get very confusing have 100 text boxes? All
prefixed with "txt", at that point the "txt" just fades in to the
background and you have the exact same problem as you did before.
 
Back
Top