Have a look at Code Conventions for the Java Programming Language - this seems to be the de facto coding standard for Java, almost all projects that I've worked on use the conventions from that document.
The names of identifiers should make their meanings obvious.
Find the conventions for JavaBeans about get and set methods.
Methods with a boolean return type usually start with "is" or "has".
Exception classes should end with Exception, similarly Listeners should have XXXListener at the end of their names.
Methods which return an instance are usually called getInstance().
jacob deiter wrote:Anyone please share best practice in naming convention in java programming such as
1) Class Name
2) Method name
3) Parameter Name
4) Interface Name
5) Helper Class
6) Wrapper Class
7) Exception class
If I missed any things please address those also
See Robert C. Martin "Clean Code" (Chap 2 & 3) where at one point it says "You should name a variable using the same care with which you name a first-born child"
Another thing I do with Lists and Iterator is append List to List objects and ListItr to the Iterator for the list.
e.g.
One of the main things is, that once you have got your convention, stick to it religiously. You'll be glad you did later on when looking back at you code, trying to debug some issue
Rusty Shackleford wrote:As long as your names are meaningful and are consistent with your convention, it doesn't really matter what convention you use.
I disagree. You're not the only one that's ever going to look at your code. Using pretty much the same conventions that the majority of Java developers use is important for working as part of a team or for any other type of collaboration.
I would say that the single most important thing is to follow whatever standard your company has. Even if it's the most borked up convention in the world, at least everything in the codebase will be consistantly borked up. If it's all the same, a developer can get their head wrapped around it easier than if everyone writes their code a little different.
If your company doesn't have a standard, then the Sun convention is the de facto one to use.
Post by:autobot
Don't MAKE me come back there with this tiny ad:
a bit of art, as a gift, that will fit in a stocking