|
because of the features in IDEs nowadays, I have left hungarian for good (I think)
I make my locals easy to understand like this underscore then camel case
_lastName
And if any one checking my code cannot understand what that is, I assume that they will point the mouse at it and Visual Studio (I use .NET) will tell them how it was declared, or they should not be programming.
Let's make things simpler than possible.
-- modified at 22:12 Friday 7th April, 2006
|
|
|
|
|
I used HN for quite a long time, but i always had a feeling that it was not "good".
This article finally told me why:
http://www.cuj.com/documents/s=7989/cujcexp1911hyslop/hyslop.htm
And after reading "C++ Coding Standards" I finally stopped using hungarian notation. in the beginning it was hard to think about variable names, but now it is no problem anymore
C++ is a typesafe language and if you name your variables reasonable there is no more need for HN.
For C style coding it might seem to be useful but as Herb Sutter already said: "Avoid Hungarian notation. It will make a liar out of you. Warts are not information, but disinformation."
lpatchRegards.
|
|
|
|
|
If you use GUIDs you never have to worry about naming conflicts, and variable scoping is highly over-rated anyways. Plus your code is automatically obfuscated. And its also great for job security (unless everyone realizes that you can't figure out your code either)
Troy
|
|
|
|
|
I don't use local variables, Did you forget about the lispers?
|
|
|
|
|
Keep it short and simple
camelCasingForLocalVariables
m_PrefixForMemberVariables
p_PrefixForPropertyVariables
David Veeneman
www.veeneman.com
|
|
|
|
|
David Veeneman wrote: m_PrefixForMemberVariables
p_PrefixForPropertyVariables
Why do you find it necessary to distinguish these two? It's very easy for a member to be exposed as a property. Do you then rename your members?
I keep it extra simple:
camelCasingForLocalVariables
m_camelCasingForFields (class members)
Alvaro
The bible was written when people were even more stupid than they are today. Can you imagine that? - David Cross
|
|
|
|
|
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconNamingGuidelines.asp
Honestly, Hungarian notation makes my eyes bleed.
Daniel Vaughan
Zen Diaphragm
|
|
|
|
|
Well i got into c# first before getting to know c++, so now i write my c++ classes with the attitude of trying to make it more C# like...If i got a public variable, i capitialize its first letter to make it like a c# property...private variables are lower case on first letter with each word after starting with upper case.
I hate hungarian to...i think it was invented for back when code was written in a notepad setting...like what kinda noob would do that now (thinks of some linux code tools that are nothing but elaborate textpads)... basically cause you didn't have something like intellisense that could tell you what type of variable something was without looking for where it was declared... now hungarian is just noise in the code! (IMHO)
C# style is as good as code can appear to me lol
thx for link: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconNamingGuidelines.asp
now when i work on a c++ game project, and invite other members, i can say...THIS is the style!!!
|
|
|
|
|
Of course public member variables are no style at all
|
|
|
|
|
Local = GoodPerson ;
Global = good_person ;
Global controls = m_ctrlname ;
Classes = CPerson ;
:->
-- modified at 5:52 Wednesday 5th April, 2006
|
|
|
|
|
Hello,
Not really a consistent approach.. Your locals are in CamelCase. Your globals don't follow a specific guideline. Your global controls are prefixed with the scope m_(ember), prefixed with hungarian notation and the actual name doesn't have a capital letter? Your classnames follow the Microsoft convention.
Why?
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
not a good approach there should be some difference
Regards
|
|
|
|
|
To keep some consistency of my source code and help people understanding it afterward, I use I slightly modified "Scope and Hungarian prefix" notation, I explained in my CSkinProgress control :
For private/protected members of a class, I start with 'mp_' (means MemberPrivate_). All these informations, though not used by the compiler, could help to understand the focus and life time of a variable (g_ stands for the whole application life time, m_ for the class life time, l_ for the method life time, ...).
The hungarian prefix helps to remind the reader what kind of variable it is. You don't always have the constructor/declaration on screen (even if all methods are supposed to fits in one screen), so it's kind to know what you are dealing with. Not every IDE have IntelliSense, I sometimes code on notepad...
This is also quite useful to chage a variable from a scope and type to another, without changing other variable. For instance, changing the mp_nSerial to m_nSerial when it has to become public, or m_nSerial to m_oStrSerial when there is no more enough space on the int value and/or you may support characters in your serial.
Don't forget you cannot use a int like a string. You may not do m_nSerial.Format("%d", GetSerial()), but m_nSerial = GetSerial() instead... That's where hungarian prefix helps, it prevent you from even thinking doing some kind of .Format(stuff)
Things to read though :
http://www.joelonsoftware.com/printerFriendly/articles/Wrong.html
http://discuss.fogcreek.com/joelonsoftware/default.asp?cmd=show&ixPost=35396
Kochise
In Code we trust !
-- modified at 3:43 Wednesday 5th April, 2006
|
|
|
|
|
Alright folks
having a bit of a problem with a datagrid. i set up the datagrid as read only to start with then using tablestyles set some columns as readonly = false.
When i first insert a new row into the datagrid it actually shows 2 lines but only 1 line is active, which i want but i don't need the want the other line.
So all i want when i insert a line into the datagrid is the line i create. It seems to do it when all datagrid read only. Is their any functions or validate checks that stop this from happening
any help is appreciated
regards
mack100
|
|
|
|
|
Wrong thread dude.
This is a thread about the result of the survey.
You get more chance getting an answer on the proper thread.
If someone says "Die mortal!", don't stay to see if he isn't.
|
|
|
|
|
Well ... someone had to vote for it!
|
|
|
|
|
For job security shouldn't we just name all variables X? Or, just one letter names from a-z. In C# you could use both "X" and "x" in the same block. You would be hard to replace if nobody but you understood your code.
|
|
|
|
|
Good idea! Bur, the trouble would be when you'll spend better part of the day understanding your own code
Cheers,
Rohit Wason
|
|
|
|
|
thrakazog wrote: just one letter names from a-z
Believe it or not, one of the first versions of BASIC for personal computers (called 'Tiny BASIC') supported exactly 26 variables, named 'A' through 'Z'.
Software Zen: delete this;
|
|
|
|
|
One of the machine tool programming languages we use used to only allow variables called V - V1, V2, V3, V4... Made programming in Brainf--k look appealing!
|
|
|
|
|
you know, code obfuscating tool exist !!
what if you (or one of your colleagues) have to maintain the code several months later ?
very bad convention sir. i strongly deprecate it
|
|
|
|
|
It also can you the wrong way, that your boss is guessing you arent a serious programmer
PS: Writing maintainble code belongs to the duties of a programmer.
Greeting from Germany
|
|
|
|
|
I just don't get these other replies. Future maintenance? What your boss thinks? Bahh!!!! Personally, I name all my variables and functions with 'l' and '1':
l, ll, l1, ll1, l1l, l11, llll, lll1, (and so on...)
I mean, take a look at the beauty of the following code:
<br />
for(ll1ll1l=l11llll; ll1ll1l=l111lll; ++ll1ll1l)<br />
{<br />
ll1ll1l1[ll1ll1l].ll1l1l();<br />
}<br />
|
|
|
|
|
Very handy dont you think?
If I was your boss and you would make code like that, you would be fired the next day. This will cost a lot of money to maintain and if you wait to long to fix code like this, you will spend even more money to fix it...
WM.
What about weapons of mass-construction?
|
|
|
|
|
I can't believe anyone actually believes I or thrakazog is serious. (At least I hope thrakazog isn't serious or he will have a hard time keeping a job.)
Obviously such code will get you fired in a heartbeat (should someone review it that is).
Here's a more subtle approach which will probably eventually get you fired, just not right away: How to Write Unmaintainable Code[^]
|
|
|
|