Pojo + ajax = KISS

Lately there has been a lot of fuss about POJOs and AJAX. POJOs (plain old java objects) are the answer to adding multiple layers of complexity just to store some simple data in a database. Some developers discovered that “hey I don’t have to bend over backwards if I just do an insert query here instead of writing dozens of deployment descriptors, ejbs and what not” and called this POJO.
Ajax on the other hand is just freeform httprequests with minimal restrictions: post something & parse the string that comes back. As such it is actually a very good drop in replacement for almost all applications of soap. Both are actually applications of the plain old KISS principle: don’t add complexity where you don’t need it. Complexity increases maintenance cost and it is only justified in a tradeoff where you gain something you need (e.g. flexibility). Soap and EJBs are examples of technologies that typically don’t justify the added complexity.

While soap can be used for more advanced stuff than remote procedures, it rarely is used in any other way than yet another remote procedure protocol. Soap calls have a number of disadvantages including performance, scalability, poor interoperability despite piles of specifications and complexity. Soap is actually not really suitable for RPC because of the high latency which forces you into a very coarse grained usage pattern (few calls with many parameters instead of many calls with few parameters). If each soap call takes 150ms, you can’t afford more than two or three in a single transaction. So soap is really optimized towards posting a really complicated message and receiving something equally complicated back. If instead you want to do something simple like “doFoo with parameter X and Y and tell me if it worked” it is much more efficient to post a small message using http to a server that understands this message and returns “true” or “false”. That’s what AJAX is about. Http posts can do roundtrips in 20ms on a good network. So you can afford to do lots of them, e.g. from a javascript running inside a browser.

That’s actually all AJAX is about because there’s no such thing as a specification which tells you how to construct an AJAX message. Neither is there a POJO specification which tells you how to construct simple java objects to store simple data. POJOs and AJAX are something you are already supposed to have: common sense. Keep It Simple Stupid.

Netbeans 4.1 Beta (2)

A few days ago I commented on my intention to try out netbeans. Sadly due to a bug in the project creation wizard, I didn’t get very far and at this point fixing things manually (by hacking the project xml file) is not something I want to do. I did manage to get a freeform java project going. However when you want to edit jsps in such a project you need something called web modules. Probably a web module is nothing else than an extra set of tags in the project xml. However, the gui doesn’t really allow you to add one by other means than using the web project wizard. And this thing crashes when you try to finish the wizard. Considering that this is a beta, I don’t think this is very bad.

Performance on the source only project was really good, by the way. I added a large project with multiple source folders and everything remained very responsive. Eclipse really chokes on this kind of project. Netbeans seems to take a more lazy approach to validating: if you don’t open the file, netbeans won’t do anything with it. Eclipse on the other hand tries to pre compile as much as possible and will tell you if there’s a problem with a file you are not editing (remove a jar file from the classpath and red error icons all over the place). While this makes netbeans very fast it also makes it less useful than eclipse: I really want to know when Foo.java breaks because I changed something in Bar.java. Of course you can manually validate the whole project simply by building it.

Additionally the code editor sucks compared to eclipse. If code editing is not your thing you won’t care but what the hell are you using an IDE for then? The fact is that the eclipse java code editor is a more powerful tool.. The eclipse code editor is probably the best feature in eclipse. Netbeans compensates by doing everything else really well and by being fast and more scalable.

There has been a lot of discussion on the www.javalobby.org forum on eclipse performance. Several myeclipse, eclipse and netbeans people bothered to respond so it is worth a read. Bottom line is that the eclipse people are now working on performance (instead of features) and the netbeans people are getting rid of the bugs in netbeans 4.1 to make it ready for release. Both IDEs should be ready in few months. Probably netbeans 4.1 will be released a few months before eclipse 3.1. However, what really matters is the eclipse web tools project which is due this summer. Only when that and eclipse 3.1 are both ready, a fair comparison can be made.

Due to the problems with the web project wizard, I can’t give a full review at this point. I will try the release candidates when they come in a few months. Preliminary conclusion is that netbeans is a very capable tool that scales very well with project size. A severe limitation is the code editor which is a rather weak offering when you compare it to eclipse.

Netbeans 4.1 Beta

I have some mixed feelings about Netbeans. Long time ago, netbeans was my favourite IDE. This was during the days that IDEs cost money, were slow and generally a pain in the ass. Up until netbeans my preferred environment was an editor, a dos box and a compiler. Netbeans fixed that. The 1.x versions were quite nice and feature rich compared to for example Visual Cafe or Borland JBuilder though clearly netbeans was the underdog and probably not very suited for larger projects either. Then SUN took over and an uninspiring batch of releases followed. The most disappointing was the 3.x series which basically confirmed that SUN was out of touch with developer reality (it didn’t fix the performance issues, it didn’t add refactoring, it kept the awkward files system mount thingy, etc.). So IBM came along and kicked their ass with eclipse 1.0, 2.0 and currently 3.0 (and soon 3.1). Basically people jumped on the eclipse bandwagon because it was the best product.

To be fair, netbeans never had much of a community. Before eclipse the IDE market was dominated by Borland, IDEA and some others. And then eclipse came along and now dominates this market to the point that most former competors are joining. Even mighty Borland has joined the eclipse project. In summary, eclipse now has lots of momentum and netbeans never had much momentum.

Yet, Netbeans is not a bad product. I (re)tried it tonight and the 4.1 beta is pretty nice. It’s fast, responsive and seems to do all the basic stuff pretty well. On top of that it is loaded with webdevelopment features that eclipse doesn’t have. And to top it off, it has very flexible project settings and can (so I’ve heard) even import eclipse projects.

Its weak spot however is Java code editing. Eclipse is extremely good at this and netbeans isn’t. Eclipse offers you autocompletion, refactoring, source transformations, templates, quick fixes, on the fly compilation and much more. Netbeans only does a small subset of this (about half the refactorings, hardly any quick fixes), impressive still but eclipse is far ahead in this respect.

However, eclipse has a major problem: it is SLOW. It has severe problems scaling to modestly sized projects. And that is why I decided to give netbeans another chance. I already know the 4.0 series is fast. On my previous work PC (a pentium III 550) it had no trouble managing the projects that currently seem to give eclipse lots of trouble on my newer and much faster desktop (a 3GHZ p4). I won’t make the switch probably because of the code editing issues and because at work the standard environment is eclipse (this is unlikely to change soon). However, I want to know what I’m missing.

Check back for an update in a couple of days.

Eclipse 3.1M5 & WTPM3

I work with eclipse at work so it’s always nice to see new goodies from eclipse.org. I haven’t had time yet to check these out but I sure will. Eclipse M4 & Web Tools Project M2 was a little shaky for me so I had to revert back to Eclipse 3.0.1 & MyEclipse. I hope the Eclipse M5 milestone will be somewhat more stable and that the WTP M3 will add the flexibility I need for more complicated projects. In M2 it still insisted on a very particular directory structure and on (needlessly) generating all sorts of stuff. This simply does not map to what I want very well. Since this is listed as one of the things that they fixed in this release, I am optimistic.

Go get the goodies here:
– http://eclipse.org/webtools/index.html
– http://www.eclipse.org/downloads/index.php

Update: definately not ready for action (WTP) :-(. Two severe exceptions whilst trying out some of the functionality. The thing started with an error about some axis jars not being available. This was in the releasenotes. Then I tried to create a web project and there things got ugly. I have no time to investigate this any further and will wait for M4.

more on subclipse

I had some more fun with subclipse today. The integration with eclipse is much better than I anticipated. Eclipse already has extensive cvs functionality. Subclipse acts as a backend for this functionality and that means you get a lot of nice features. I was also pleasantly surprised with how well subclipse performs. Overall I am not so happy with eclipse in this respect (rebuilds suck and they happen a lot). But at subclipse seems to do well (compared to tortoise svn and commandline svn). Of course the bottleneck is network and disk io and doing this in Java doesn’t seem to have much performance impact. Things like getting svn logs for directories actually seems to work faster. Also I absolutely love the diff tools in eclipse.

tomcat and iis

I had to look into some configuration issues which I had been delaying for the past few weeks. How to get iis to play nice with tomcat such that you can have two virtual iis servers forward stuff to one tomcat with again two virtual servers.
We have two tomcat applications that we need to shield from the outside world with a webserver like apache or iis. How this works is that the webserver forwards some urls to tomcat and acts as a proxy for those urls.

This is pretty routine stuff, the only problem is that it is not documented how one should do this. And lets face it, the apache jakarta people write beautiful code but their documentation is typically not that good. You can get started easily but the advanced stuff is understandably not documented well. I say understandably because I understand that developers have other priorities (like getting things to work) but still, it’s bloody unusable now.

But I figured it out today thanks to this page: http://tjworld.net/help/kb/0001_iis6-Tomcat5-JK2.html#conConnector. This page contained all the necessary information to get me started. I followed the instructions to the letter and ended up with a working iis-tomcat setup. From there it was easy, just add a few hosts to the tomcat server in server.xml (I’m going to experiment with the alias tag later on) and add a bunch of iis virtual services (all with the isapi filter active) for each of the tomcat hosts. Works just fine. I knew all along that it was possible to do this and now I have the proof :-).


For the zillionth time I decided to spend some time trying to get subclipse (http://subclipse.tigris.org/) to play nice with our svn+ssh repository at work. For those scratching their heads: eclipse is a popular java development ide; subversion is a version management system and subclipse is a subversion backend for eclipse’s team synchronization functionality. Until recently subclipse did not support subversion repositories secured with ssh, which unfortunately is a very common type of subversion repsository (and also very easy to setup). So, no subclipse. The reason was that subclipse depends on a native subversion library which in turn depends on the presence of ssh. That’s a lot of dependencies and it doesn’t work without a lot of tinkering and even then it may not work.

But the good news is that the guys at http://tmate.org fixed things for the subclipse guys by providing a java only implementation of the svn library. I installed it today and it works beautifully. The eclipse team synchronization stuff looks really useful and with subclipse finally working I can now put it to work.

Anamorphic aspect ratio calculator

Anamorphic aspect ratio calculator. I sometimes play movies from my PC to my widescreen TV. Unfortunately the tvout of my Geforce 4 card does not support widescreen. In other words, it sends a signal with a 4:3 aspect
ratio to my tv. Luckily my tv can stretch the image to 16×9. Normally this would result in a flattened picture on the tv, which is not the intention. So suppose you have a cinematic dvd movie (aspect ratio 11:5) and want to play it on the tv. If you just send it to the tv, you’d have a 4:3 picture with enormous black bars ontop. Using the zoom function of the tv it will display fine but you are also not using a significant amount of tv signal so you’re losing precious pixels!

What you can do instead is change the aspect ratio of the movie and let the tv stretch it back to its orginal 11:5 aspect ratio. The new aspect ratio for the film is called the anamorhic aspect ratio and you can
calculate it with this neat little calculator I created. You can enter the results in bsplayer,
which allthough enormously feature rich does not have an anamorphic setting built in (at the moment of writing) and play your movie using the full available resolution and enjoy the extra detail :-).

The jar file can be started by double clicking on it (windows, must have a Java 2 jvm installed of course) or running “java -jar anamorphic.jar” from the commandline. Source code in the form of an eclipse project can be found here.

If this all sounds too nerdy, just download media player classic from sourceforge.net and use the options->pan&scan->scale to 16:9 option to get the same effect.