I'm new to Java and Javascript(which i know is kind of unrelated to Java but it is to my question". Sooo, why do seemingly random function names and variables in the Head First books as well as one in the Java API have every word after the first capitalized(hopefully you know what I am talking about)? And then others have everything lowercase. It's really annoying because I'm used to having everything lowercase because I end up making more mistakes when I start capitalizing function names and variables. I'm just curious to know the naming conventions you more experienced programmers use, and what the better habits are to pick up.
Just pick the style you like the best and stick with it. The important thing isn't which style you use, but to be consistent throughout the code, all for the purpose of making it easier for you to read and scan quickly with your eyes.
One common style is to use underscores/lowercase for private data (some_private_variable), and camel case for public (somePublicMethod). It's not set in stone, it just makes it easier for your eyes to pick things out faster.
Vance Montague wrote:Just pick the style you like the best and stick with it. The important thing isn't which style you use ...
While that may be true of things like number of spaces to indent, or where the {}'s go, I'd not screw around with the naming conventions.
Not following the established naming conventions for Java code makes code surprisingly hard to read. If you want the Java community to help you with your code, follow the conventions. Otherwise, your posted code is likely to just be ignored.
Plus tool support will suffer severely. Even some frameworks will not work, at least for Java beans and frameworks that utilise them (some) naming conventions are mandatory.
Vance Montague wrote:Just pick the style you like the best and stick with it. The important thing isn't which style you use, but to be consistent throughout the code, all for the purpose of making it easier for you to read and scan quickly with your eyes.
One common style is to use underscores/lowercase for private data (some_private_variable), and camel case for public (somePublicMethod). It's not set in stone, it just makes it easier for your eyes to pick things out faster.
using the style which suits you makes the code easily readable by you only.What about others.So why not use the coding standards so that the code is easily readable by others.
camelCase -- remember... it is more important that your variables, methods, etc be understandable rather than just brief. The name of methods (verbs really) should be similar to: getSomething or setSomething or doSomething.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.
subject: A question about something that has been annoying me.