08 January 2008
for once in my lifetime...
... I'm actually (fairly) happy with the design of one of my Java programs. I'm crap at design, I always try to decouple too much and end up with writing loads of bridging code that doesn't really do anything. This time it seems like I've found a good balance... well, we'll see if/when this little thing will actually be released.
Meanwhile, KDelicious is picking up steam, thanks to my relentless advertising :) -- it's now on Freshmeat too!
Labels: GeekDiary, java, jeBlogger, kdelicious
posted by GiacomoL @ 3:40 PM 0 comments links to this post
jEdit plugin for Thinlet dev
Too bad I won't use it soon, but here's a nice jEdit plugin to display Thinlets in realtime as you modify the XML.
Labels: GeekDiary, java, jedit, Thinlet
posted by GiacomoL @ 2:37 PM 0 comments links to this post
21 November 2007
On the Samurai Principle
Some blogs recently pondered on the Samurai Principle. It made me think, because I'm one of the many "guilty" of returning None/null rather than raising an exception. To me, it happens more often when working with Python rather than Java, because it's very natural to write "if something_not_found: return None". Also, abusing exceptions can end up polluting your code with dozens of nested try-catch/except, which kill readability and tend to be much worse than a simple "if (obj is None):".
This said, I agree that NullPointerExceptions are a royal pain, and "AttributeError: 'NoneType' object has no attribute 'something' " is equally bad to deal with. API programmers in particular should try hard to return this sort of stuff as little as possible.
I guess the bottom line is that in medium stat virtus, as it's often the case with these "absolute principles of programming"; at the end of the day, when we program we are applying science, not demonstrating it. And as much as we love them, samurai lost all their wars ;)
Labels: GeekDiary, java, python
posted by GiacomoL @ 1:40 PM 3 comments links to this post
29 October 2007
Pain can be useful
So, I've spent a few hours improving my little J2ME project. It's pretty much done, what I need now is a little bit of polishing and, more importantly, the server-side app, which I just started to "conjure up" in django.
I didn't remember how painful Java development can be. Fixed-size arrays, .put() and .get() every five seconds, loads of redundant declarations (if a method can only return a String, why should I also declare that a reference to the result is of type String? what else could it be?), not having an interactive environment to quickly test out ideas. Eclipse goes a long way to reduce the pain, but it's still so much more painful than doing the same thing in Python. And when everything is done... NullPointerException.
The good side is that fear of pain forces you to really think things through before you write them down. In Python, I end up re-writing things over and over again, because there's no (perceived) penalty in doing it, and I more or less "code my thoughts"; of course, I eventually end up spending lots of time on this sort of messing.
With Java, I'm forced to think about the proper structure up-front, because I dread having to write it down more than once; but this means that it's then a matter of monkey-coding a clear structure, and once it's done, it's done, and I can get on with other things.
Labels: eclipse, GeekDiary, j2me, java, python