Monday, April 28, 2008

re: JSR-666 Extension: Significant whitespace

i just read JSR-666 Extension: Significant whitespace, and while i get the JSR-666 (The Java Specification Request from Hell), i'm not sure if i understand if the posting was a joke or not.

In many software development teams that I've worked on, code reviews are done by printing out the code to be reviewed. This is in turn read and scribbled on with red ink by developers suffering from a delusion that their coding standard is better than mine. An example of some such code:

public boolean equals(Object o)
{
try
{
if (Calendar.getInstance().get(Calendar.MONTH) == 1
&& Calendar.getInstance().get(Calendar.DATE) == 29)
{
return true;
}
else
{
Thread.sleep(10000);
return new Random().nextBoolean();
}
}
catch (Throwable t)
{
// Something must have gone wrong, try again
return new Random().nextBoolean();
}
}


When reading the above code, the obvious problem that jumps out is that it contains no less than ten curly braces. When printed for a code review, this is a waste of valuable ink. The squids of the world have been working overtime to provide the ink needed to print out all the code that needs to be reviewed, it is about time we gave them a break. I'd therefore like to propose to the JSR-666 expert group an extension that curly braces be replaced with significant whitespace.

The previous code example would become:

public boolean equals(Object o)
try
if (Calendar.getInstance().get(Calendar.MONTH) == 1
&& Calendar.getInstance().get(Calendar.DATE) == 29)
return true;
else
Thread.sleep(10000);
return new Random().nextBoolean();
catch (Throwable t)
// Something must have gone wrong, try again
return new Random().nextBoolean();


A fine piece of code that would pass any code review.

This feature will also solve a number of other problems, for example, it will eliminate the age old argument over whether braces belong on a newline or not. It will also force developers to write neatly structured code.

This feature will not require any JVM changes, but will require compiler changes. Existing code may need to be changed, however, if the existing code was well formatted to begin with, it should suffice to simply run the following command in vim: :%s/\{|\}//g


i guess its april fools again. its actually funny cause this dude works at atlassian. so, my guess is that this crazy blog posting was actually some sort of marketing ploy to market crucible. (so, i guess i might have to explain why its funny.... so, its funny cause i hope that atlassian people; people that develop software development tools, use their own products and not paper code review). thats the only conclusion that i can come up with. i guess it the marketing ploy worked cause i'm on my blog talking about crucible. anyway, crucible looks like a pretty good tool and we plan on giving it a serious try.

anyway, sorry for this boring post. i just thought his posting was funny.

No comments: