ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Other Software > Developer's Corner

Coding Standards

<< < (2/2)

Renegade:
At the risk of sounding like a heretic, Hungarian has some merit.

I'll stop there before I get lynched. :)

f0dder:
wraith: Be a rebel - APPEND the underscore!

Renegade: if used properly, yes - most people tend to think hungarian means prefixing the data type ("i" for integer, "s" for string etc, "p" for a pointer etc), which is pretty pointless. If used for the purpose of the variable, the logical data type, it holds some merit... like "cb" for "count (in bytes)".

worstje:
I prefer the _ prefix myself as well. While a lowercase first letter might work for private variables, it is just too easy to write or read the wrong thing. I've had it happen more than once that autocomplete (or maybe my temperamental shift key - I am not sure yet) caused the wrong one to be put in. It's caused a few nice stack overflows because the property accessor kept looping into itself, which is really bloody annoying.

Hungarian notation is nice, but it needs to be sensible hungarian, not the overly verbose whats-the-point hungarian that adds no extra information. For more information, see Joel On Software: Making Wrong Code Look Wrong.

Renegade:
Ok, I'll come out of the closet then...

Private variables?

Type _variableName;


Public members?

Done as properties like:

VariableName
get { return _variableName; )
set { _variableName = value; }


Methods? Pascal case:

private void SomeMethod()


Local variables? camelCase:

Type someVariable;


Interface components? Pure Hungarian. e.g. Check boxes are:

chkSomeBoxPurpose

A list?

lstSomething

A text box?

txtWhatIsit

Similar for other components.


I like Hungarian. It's easy to work with and is clear. I really don't care about the anti-Hungarian hype/crap. I'm all for stuff that works and is simple and understandable. :)

EDIT: Fixed a drunken error. :)

wraith808:
^ You've got my preference almost *exactly* written there.  And interfaces, I append I to it, i.e. IMyInterface.  Generic types, I use T.

And worstje hit the nail on the head with why I've been having *so* many problems.  I just can't figure out how intellisense alphabetizes, but it seems that no matter what order I declare them in, I get the problem of it autocompleting with the wrong case.  AIEEEE!

And up until now, it wasn't really that bureaucratic before the beginning of the year.  We have a product side (that deals with client facing apps) and a content side (that deals with internal apps used to create content).  They decided to merge all of the developers into one happy group (yay...?) so this is an attempt to help with that.  As such, I can see the need for a unified standard.  It's just that the upper and lower case is *really* slowing me down, just as I've started to try to minimize the use of the mouse.

Something else I've noticed- the change in your personal coding standards as you go through career development.  My personal code is a mixture of things, purely because of my history as a contractor, and going from place to place, having to adapt.  I looked at a bit of code that I posted in the SQL injection thread, and gagged because I had all of the variables defined in pseudo hungarian, i.e. strThisString, etc.  I was so put off from it, that I actually had to change it, but missed an instance of a variable.  And that's not the first time I've had that issue.

Just an observation...

Navigation

[0] Message Index

[*] Previous page

Go to full version