Last.FM: Recently listened

Tuesday, August 23, 2005

[Java Adventures] Remote Method Invokation

I've been learning Java RMI today. I currently do not yet know whether I like it or whether I should better hate it.

It has some nice features, sure:
  • Work with a remote object,
  • Do not care for setting up a connection to the remote server - this is done by RMI for you, and
  • Do not care for the way parameters are sent around - your remote objects can have every data type you want, as long as this type is serializable. Marshalling (packing the parameters into nitty little TCP packets) and unmarshalling (the same vice versa) is performed internally by the magics of Java reflection.
All of the above features make your distributed application become clear and easy - your client simply looks up a remote object and then works on it as if it was a local one.

So why should one hate it? - Well, it is the above mentioned magic. Magic makes development easy, but it hides problems from the user. In many cases one will probably build a cleaner and maybe even faster solution by transferring data manually over a TCP socket connection.

Furthermore, I had some bad minutes searching for subtle exceptions thrown by my RMI application - took me some interesting command line arguments to get the JVM to do what I needed. This is not that bad - solutions are available from Google within seconds, but this is what makes learning RMI probably not that easy for beginners.

All in all: have a look at his grown-up technology and enjoy its ease. But keep in mind that sometimes it is just as breaking a butterfly on the wheel.

I found the following tutorials helpful today:

No comments: