Skip to main content

Adapt the Java style for your own

Posted by malcolmdavis on February 29, 2004 at 9:21 PM PST

Getting C/C++ developers to adapt new coding conventions can be frustrating to a team lead and other Java developers. Coming from a C/C++ and Microsoft background, my style was somewhat different from Sun's guidelines. I found that I was reformatting code all the time to my own convention. Reluctant to change my ways, and looking for every justification in the world not to, I asked experts for guidance. Then Bruce Eckel gave me some words of advice that are paraphrased as follows:

"..not only has Sun worked it all out (and why re-invent a good wheel), but more importantly because everyone sees the Sun code and becomes used to it -- why add the extra mental cycles necessary to shift gears every time you jump to 'your format.'"

After reading Bruce's comments, I got over my ego, and changed my coding habits. Within a few months, the Sun style had become my native convention and I had successfully re-tooled 10 years of C/C++.

While the changes might seem minor and insignificant, I had a huge increase in productivity due to Java comprehension. [It's interesting how much an ego can get in the way of being a better programmer.]

Sun's Code Conventions for the Java Programming Language can be found at


  • The Java certification exams given by Sun use the code convention. If you plan on becoming certified, adapting to the Java style will help.
  • Even though code-reformatting tools exist for every environment, code reviews go much smother if everyone is using the same standard.
  • It helps with the understanding of the reference material from books, professional journals, and Java technology specifications.
  • Having one global standard helps between hired developers, or developers inside a huge IT organization.

Thank you Bruce. :-)

Related Topics >>