« Previous day (Jun 12, 2005) | Main | Next day (Jun 14, 2005) »

20050613 Monday June 13, 2005

See you soon?

JavaOne logo JavaOne 2005 is getting closer. I'm hoping many of you will be able to make it. One of my favorite things about the conference is meeting people, especially users, and now with this blog, readers!

If you haven't been able to talk your boss into sending you to JavaOne, you should still come to NetBeans Day the day before - it's free. Check out the list of speakers! I'll be giving a Creator demo there. Be the first to see Creator, The Next Generation! (As you can see from the schedule, there are two tracks, and the Creator talk is track B around one o'clock.)

At JavaOne, I will also be giving a talk on AJAX, with Greg Murray, the Servlet specification lead:

TS-7986: Rich Web Applications With the J2EETM Platform and AJAX
It's not a Creator talk; we will discuss strategies and implementation issues for implementing AJAX-based web applications on the J2EE platform. Be there or be static. (Put it in your schedule now. Tuesday, June 28, 11am - Esplanade 307/310. Room capacity 1200.)

I might also be involved in some other demos but that's still TBD. And of course, I'll be hanging around the Creator booth a lot, so if you find it (which wasn't easy last year - I hope we get a better spot) please stop by and introduce yourself!

Last but not least - not even CLOSE to least - the parties! I'm not sure if we're having a Creator party, but if we do, I'm there. And I definitely don't want to miss the Borland party! And I'll try to crash as many other events as possible too!

(2005-06-13 11:09:25.0) Permalink

OnlyOneReturn Considered Harmful

The other day I mentioned PMD and how it's vital to learn how to customize the ruleset, since by default it includes some rules that are evil. Evil I tell you!

My favorite rule to hate is the OnlyOneReturn rule. This rule basically says that

A method should have only one exit point, and that should be the last statement in the method.
Unfortunately, the rule author does not provide supporting documentation for this point of view, and I personally cannot think of any. In fact, restricting yourself to a single return statement makes the code less readable. Take the following method from the JDK's Integer class for example.

    public static String toString(int i) {
        if (i == Integer.MIN_VALUE) {
            return "-2147483648";
        }

        int size = (i < 0) ? (stringSize(-i) + 1) : stringSize(i);
        char[] buf = new char[size];
        getChars(i, size, buf);

        return new String(0, size, buf);
    }
We have a special case, and it's dealt with right at the beginning of the method. If we hadn't done that, we would need to slap a big else block around the remainder of the code, as well as introduce a temporary variable, e.g. result, to hold the return value that we then return as the last statement of the method.

The above is a trivial example, but I frequently write code where I have multiple exit points early in the method that deal with special cases, and this avoids the need for deeply nested code.

Creator's Visual Page Designer Source Code: Proud OnlyOneReturn Rule Violator Since 2003.

(2005-06-13 10:52:23.0) Permalink Comments [9]