The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
December 2000

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Naming conventions

Posted by Bill Barone on December 18, 2000 at 11:25 AM

> > I am learning Java. Are there any standard naming conventions in Java which I should be using for my own benefit and for the benefit of other people reading/debugging my code?

> > Thanks,
> > Zahid

Very definite naming conventions especially when it comes to javaBeans. Most books on java cover them. You may want to download Tbinking in Java by Bruce Eckel at bruceeckel.com it is well worth the effort. as for some of the conventions commonly accepted that are not required by beans:

packages are all lower case

classes begin with a capital letter.

methods begin with a lower case letter and each word after is
capitalized i.e. getSomething();

getxxxx and setxxxx are generally accepted as access methods to private variables, and are generally used even within the class.

constants are all caps.

member variables are generally prefaced with m_xxx

USE LONG NAMES such as departmentNumber = not dpnm or depnum or some such

Remember, java is totally case sensitive. All conventions are just that, conventions and not rules. A little time under your belt reading other code will make all conventions obvious, both naming conventions and coding conventions.





Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us