aspose file tools*
The moose likes Beginning Java and the fly likes A question about something that has been annoying me. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "A question about something that has been annoying me. " Watch "A question about something that has been annoying me. " New topic
Author

A question about something that has been annoying me.

Brian Fenno
Greenhorn

Joined: Nov 24, 2010
Posts: 3
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.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60055
    
  65

camelCase


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Greg Brannon
Bartender

Joined: Oct 24, 2010
Posts: 557
Java naming conventions are specified near the middle of this page.


Learning Java using Eclipse on OpenSUSE 11.2
Linux user#: 501795
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

Brian Fenno wrote:I'm just curious to know the naming conventions


Code Conventions for the Java™ Programming Language


luck, db
There are no new questions, but there may be new answers.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36501
    
  16
Note these are conventions not rules, but many companies insist their staff follow the local variations of these conventions.
Vance Montague
Greenhorn

Joined: May 13, 2011
Posts: 6
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.
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3169
    
  10
Vance Montague wrote:Just pick the style you like the best and stick with it.

You may not have a choice. Many companies have their own in-house style guides. You need to be flexible.


Joanne
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60055
    
  65

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.
Hauke Ingmar Schmidt
Rancher

Joined: Nov 18, 2008
Posts: 371
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.
randy orton
Greenhorn

Joined: May 20, 2011
Posts: 15
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.
Harlin Seritt
Greenhorn

Joined: Apr 22, 2008
Posts: 4
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://aspose.com/file-tools
 
subject: A question about something that has been annoying me.
 
Similar Threads
quality posting
Property="*" and null form fields
regex code to recognize fully qualified Java class names in strings?
MySQL naming conventions?
My very first assignment in Java, did I do ok ?