CamelCase naming convention
-
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 :)
-
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 disliked underscores in names for a reason no one has mentioned: When I am visually scanning code, spaces between strings of characters indicate the end of one name and the beginning of another, and underscores look a lot like spaces. This makes it harder for me to understand the code quickly. Code and prose are two different things. Of course, I also strongly dislike having to add that extra underscore character with a shift and awkward reach to a key at the top of the keyboard that I have to look for, since it falls outside the scope of my touch typing practice. And, in some display situations, the underscore disappears in an underline of the whole name. And, what is most frustrating, I have occasionally seen two or more underscores used together. In many fonts, it is very difficult to tell how many underscores there actually are.
-
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 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 Unsure. Just a matter of choice. And I find the CamelCase notation not really difficult to read or write.
totally agree... I hate using underscores in methods and variable names.. I think the best and easiest to read and write is CamelCasing :) ICouldReadACamelCasedBookWithoutAnyProblems :-D