Sun Java Coding Conventions Revisited

Posted on March 6, 2010. Filed under: Uncategorized | Tags: , , , , , |

The Sun Java Code Conventions document, written in 1997, and available at, continues to be a valuable resource for Java programmers. In addition to the nuts and bolts of formatting and the like, it includes some great wisdom, such as:

The frequency of comments sometimes reflects poor quality of code. When you feel compelled to add a comment, consider rewriting the code to make it clearer.

I’ve recently been asked to participate on a committee that will come up with a set of coding standards. These standards will be used by several teams, so it’s especially important that they be good and not overly restrictive. The Sun conventions are a reasonable place we may start. On the whole, I think they’re great, but I do have some reservations about a few points. Below are some notes regarding the Sun conventions, listed by section in the original document to which they refer. Quotes from the Sun document are indicated in italics, except for source code. I invite your feedback. This article may be modified based on your comments or my own “clearer thinking and better information”.


Read Full Post | Make a Comment ( 3 so far )

JRuby — A Better Language for the Java Virtual Machine

Posted on February 26, 2009. Filed under: Uncategorized | Tags: , , , , , , , , |

A powerful synergy results when combining the power, reliability, portability, and rich library set of the Java platform with the power and flexibility of JRuby.  This article will discuss a couple of ways in which JRuby surpasses Java as a programming language for the JVM:

  1. Code as first class objects – code blocks, lambdas, and procs can exist and be passed around for the most part like any other objects. There is no need to create a class to contain them as there is in Java.
  2. Syntactic sugar for the specification of hash values as parameters – hash (map, in Java lingo) key/value pairs can be passed to a function literally, and the function will receive them as a single hash. In other words, they can be passed without the need for the programmer to create and populate a hash instance.

In order to contrast Java and JRuby, and showcase the above features, we will implement a Fahrenheit/Celsius temperature converter in both Java and JRuby that uses Java Swing as its GUI library. The source code can be found at (The Git repo main page for this project is at The README file has instructions for how to run the Java, Ruby, and Clojure versions.

Here is an image of the application’s sole window.  There are text fields for entering the temperature, and buttons and menu items to perform the conversions, clear the text fields, and exit the program.

The Fahrenheit  Celsius temperature conversion Swing app window

the temperature conversion Swing app window


Read Full Post | Make a Comment ( 4 so far )

Liked it here?
Why not try sites on the blogroll...