05.10.09

Paranoid code

Posted in java at 11:33 pm by Twm

I’ve been wrestling with some legacy Java ME code in which the author doesn’t seem to have grasped the “do or throw” pattern.
That is, a method either returns a valid object OR throws a exception. You do not need to check the return value of a method satisfying this criterion as it can never be null.
e.g:

    Thread t = Thread.currentThread();
    if ( t != null )
        t.sleep( seconds * 1000L );

That could be simplified to just:

Thread.sleep(seconds * 1000L);

There’s something existential about code that wonders if it’s the current running thread.

04.02.08

Java bashing

Posted in Development, Python, java at 12:40 pm by design

Quite amusing theme from Eric Burke.

http://stuffthathappens.com/blog/2008/03/30/an-8-year-olds-first-impression-of-java/

http://stuffthathappens.com/blog/2008/03/31/the-right-tool-for-the-job/