CamelCase naming convention
-
grgran wrote:
wouldn't this be better: Gmpdff()
Nah - you still need to hit the Shift key. Maybe: gmpdff()
-
Why most programmers (at least Windows and Java programmers) use this horrible notation? It is both hard to write and hard to read:
GetMyPreciousDataFromAnXMLFile()
With undrescores it is at least easy to read if not to write:
get_my_precious_data_from_an_XML_file()
And of course, there is always a way to make it easy to write but hard to read:
getmypreciousdatafromanXMLfile()
Lispers have the best of both worlds (well, except for the parentheses):
(get-my-precious-data-from-an-XML-file)
I feel better now - feel free to vote me down :)
-
Why most programmers (at least Windows and Java programmers) use this horrible notation? It is both hard to write and hard to read:
GetMyPreciousDataFromAnXMLFile()
With undrescores it is at least easy to read if not to write:
get_my_precious_data_from_an_XML_file()
And of course, there is always a way to make it easy to write but hard to read:
getmypreciousdatafromanXMLfile()
Lispers have the best of both worlds (well, except for the parentheses):
(get-my-precious-data-from-an-XML-file)
I feel better now - feel free to vote me down :)
Actually as a JS coder I preffer that naming:
//Get My Precious Data From An XML File
gmpdfaxmlf();Publish the code without comments :) And make sure you keep copy of it with comments! :P
-
Why most programmers (at least Windows and Java programmers) use this horrible notation? It is both hard to write and hard to read:
GetMyPreciousDataFromAnXMLFile()
With undrescores it is at least easy to read if not to write:
get_my_precious_data_from_an_XML_file()
And of course, there is always a way to make it easy to write but hard to read:
getmypreciousdatafromanXMLfile()
Lispers have the best of both worlds (well, except for the parentheses):
(get-my-precious-data-from-an-XML-file)
I feel better now - feel free to vote me down :)
I have always used Camel Case because it is easy to read. I hate reaching for the underscore anyhow. Give me the main three rows of keys for ease of typing. Anyhow it is part of the accepted coding conditions for VB programming.
-
Where I work we use both at the same time, so everyone is offended :) CamelCaseForClassAndTypeNames underscores_for_variable_and_method_names
M Towler wrote:
we use both at the same time, so everyone is offended
But at least everybody knows the other side is offended as well :)
-
I have always used Camel Case because it is easy to read. I hate reaching for the underscore anyhow. Give me the main three rows of keys for ease of typing. Anyhow it is part of the accepted coding conditions for VB programming.
Terry Meritt wrote:
Anyhow it is part of the accepted coding conditions for VB programming.
I admit I didn't have VB in mind when I started the thread :)
-
I really don't like having underscores in method or variable names :~. Just a matter of choice. And I find the CamelCase notation not really difficult to read or write.
Cédric Moonen Software developer
Charting control [v2.0 - Updated] OpenGL game tutorial in C++Cedric Moonen wrote:
I really don't like having underscores in method or variable names
Agreed. I'll manage either way but I prefer keeping a single symbol (variable/method name) easily discernable unlike:
unfortunately_wrong_because = this_symbol - looks_a_lot_like - this-symbol;
-
Why most programmers (at least Windows and Java programmers) use this horrible notation? It is both hard to write and hard to read:
GetMyPreciousDataFromAnXMLFile()
With undrescores it is at least easy to read if not to write:
get_my_precious_data_from_an_XML_file()
And of course, there is always a way to make it easy to write but hard to read:
getmypreciousdatafromanXMLfile()
Lispers have the best of both worlds (well, except for the parentheses):
(get-my-precious-data-from-an-XML-file)
I feel better now - feel free to vote me down :)
To the OP: agreed, in general. But for small variable names, camelCasing is definitely easier and doesn't exact too harsh a reading penalty. The difficulty in reading grows with each word added, so if you can keep your names to two-three individual components, you should be all right. By contrast, sticking in a bunch of underscores can seriously extend the length of a variable name, which I begin to find just about as onerous as reading scrunched names. So, my advice is to use underscores if you really need them, but be as sparing as possible. (Hint: they do make a great way to abbreviate certain groups, such as "to", "of the", and other article conglomerations.)
-
...oh, and Lisp is cool. And so is Haskell :) Definitely been hanging too much with the dark side :). But this all leads me to believe, without doubt, that you're wrong. Speaking of inane deductions, which your post exemplifies! ;P
Paul
The flight towards the light I'll stay in the lava for life Ísland
If you want to talk about the dark side, I've been working in Perl lately! So I use what's appropriate for the language. For C++, I use camelCase. For Perl, I use @the_underscores. (I do have to admit - C#? Get away, get away! is my opinion about that language.)
-
Terry Meritt wrote:
Anyhow it is part of the accepted coding conditions for VB programming.
I admit I didn't have VB in mind when I started the thread :)
The best thing would be for everyone to follow the accepted coding conventions for the language they are using. Sure makes it a whole lot easier when you have to take over an existing project if the previous programmer did use the coding conventions. I have re-written enough apps in my time because the orginal or previous programmer didn't follow them and it took me extra time to decode.
-
The best thing would be for everyone to follow the accepted coding conventions for the language they are using. Sure makes it a whole lot easier when you have to take over an existing project if the previous programmer did use the coding conventions. I have re-written enough apps in my time because the orginal or previous programmer didn't follow them and it took me extra time to decode.
Terry Meritt wrote:
The best thing would be for everyone to follow the accepted coding conventions for the language they are using.
Sure. However, for languages such as C there are no accepted coding conventions and the usage varies drastically.
-
I would refer the honourable gentleman to the following[^]. Of course, each to his own, but the document above is possibly the reason as far as C# is concerned.
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”
Henry Minute wrote:
the document above is possibly the reason as far as C# is concerned
It's more that Microsoft language source has always been camel and pascal case (formerly adorned with Hungarian).
Kevin
-
Why most programmers (at least Windows and Java programmers) use this horrible notation? It is both hard to write and hard to read:
GetMyPreciousDataFromAnXMLFile()
With undrescores it is at least easy to read if not to write:
get_my_precious_data_from_an_XML_file()
And of course, there is always a way to make it easy to write but hard to read:
getmypreciousdatafromanXMLfile()
Lispers have the best of both worlds (well, except for the parentheses):
(get-my-precious-data-from-an-XML-file)
I feel better now - feel free to vote me down :)
I agree that underscores are easier to read. Eiffel follows this convention precisely for this reason. However, I personally find camel and pascal easier to write. You're mainly a C++ guy aren't you? So I guess you're most likely immersed in the likes of STL and Boost, which use underscores?
Kevin
-
Nemanja Trifunovic wrote:
Lispers have the best of both worlds (well, except for the parentheses): (get-my-precious-data-from-an-XML-file)
Surely Lispers should have ...
(get-my-prethiouth-data-from-an-EkthML-file)
?------------------------------------ "I am always serious about what I do, not necessarily about how I do it." Tom Baker
ThatShouldHaveBeenTheLastWordOnTheMatter but IF-ALL-YOUVE-GOT-IS-A-BAUDOT-TELETYPE-THEN-YOU-DONT-HAVE-THE-LUXURY-OF-LOWERCASE which is probably why Cobol & Fortran programs usually employ HYPHENATED-UPPER-CASE
-
Why most programmers (at least Windows and Java programmers) use this horrible notation? It is both hard to write and hard to read:
GetMyPreciousDataFromAnXMLFile()
With undrescores it is at least easy to read if not to write:
get_my_precious_data_from_an_XML_file()
And of course, there is always a way to make it easy to write but hard to read:
getmypreciousdatafromanXMLfile()
Lispers have the best of both worlds (well, except for the parentheses):
(get-my-precious-data-from-an-XML-file)
I feel better now - feel free to vote me down :)
I usually use both when I get stuck with a long name. Why not Get_MyPreciousData_From_AnXMLFile() I find this makes it easier to read the key components by grouping adjective/noun groups and separating with underscores. In practice, I find I rarely have to use this and when I do, I usually only need one underscore and never more than two. My real preference would be break the operation into objects and use myXMLFile.PreciousData() or myPreciousData.LoadFrom(myXMLFile) or new PreciousData(myXMLFile) When push comes to shove, though don't pick an either-or solution. Combine them for easiest reading.
-
Steve_Harris wrote:
As you have to press Shift to get an underscore, I'd say about the same.
Exactly - which is why I said that underscores are easy to read but hard to write.
Nemanja Trifunovic wrote:
Steve_Harris wrote: As you have to press Shift to get an underscore, I'd say about the same. Exactly - which is why I said that underscores are easy to read but hard to write.
NOT EXACTLY. You have to insert 16 EXTRA shifted characters, so that is 32 EXTRA key presses for the same lower-case function call - 16 shifts and 16 underscores extra, versus 16 extra shift for upper-case only. Personally, I don't like UGLY code, and mixing styles makes the overall code ugly. So, I use the MS standard (standard of the language/day) or the Linux/C standard, or Borland, or whatever, just so there is a common style throughout. strHungarian, under_scores, CamelCase, or _ALLCAPS - use them all. Not saying I like it, but the code is pretty. Now, if it would only work as well as it looks. X|
Gary
-
Why most programmers (at least Windows and Java programmers) use this horrible notation? It is both hard to write and hard to read:
GetMyPreciousDataFromAnXMLFile()
With undrescores it is at least easy to read if not to write:
get_my_precious_data_from_an_XML_file()
And of course, there is always a way to make it easy to write but hard to read:
getmypreciousdatafromanXMLfile()
Lispers have the best of both worlds (well, except for the parentheses):
(get-my-precious-data-from-an-XML-file)
I feel better now - feel free to vote me down :)
-
Why most programmers (at least Windows and Java programmers) use this horrible notation? It is both hard to write and hard to read:
GetMyPreciousDataFromAnXMLFile()
With undrescores it is at least easy to read if not to write:
get_my_precious_data_from_an_XML_file()
And of course, there is always a way to make it easy to write but hard to read:
getmypreciousdatafromanXMLfile()
Lispers have the best of both worlds (well, except for the parentheses):
(get-my-precious-data-from-an-XML-file)
I feel better now - feel free to vote me down :)
I can read camelCase more easily than underscores. Mainly because I've seen much more camelCase code. The extra benefit is that I have shorter lines because of shorter variable names. I try to keep within 80 characters of width per line because I hate scrolling horizontally. Doing underscores feels unusual because I'm not used to holding Shift and hitting any key outside of the character keys.
-
Computafreak wrote:
IHaveNeverReallyHadThisProblemBecauseIFindItEasyToBothReadAndWrit
You find that easy to read? :~ As for ease of writing, how many time did you have to press Shift?
Dude, really... that's like asking how many times you has to press the letter 'e'. What is it about everyone that is scared of typing? C++ people say that VB is 'too verbose'. now the discussion about uppercase letters... Just work in assembler, or machine language.
-
M Towler wrote:
we use both at the same time, so everyone is offended
But at least everybody knows the other side is offended as well :)