Archive for April, 2008

[K]ubuntu 8.04

April 28, 2008

Last week I have installed Kubuntu 8.04 on my machine. And I have got a pleasant surprise. First time in my life, all hardware are functional after a Linux installation. My wireless card, Marvell Libertas based, required ndiswrapper, which was not on the installation CD (it’s supposed to download the driver of the network card), and I installed it manually with a memory stick.

Next, the nVidia Geforce 7 card (on the motherboard) required nVidia “proprietary” drivers. Since it works, I don’t see an issue with the lack of open source drivers.

The big surprise was the sound card, not recognized by other older distributions; no configuration was required and it “simply worked” after disabling the KDE sound manager.

Enabling Compiz under newly installed video driver was also easy and near the window effects I could find some useful shortcuts, such as full screen for any window. Also fonts are looking better rendered than with the standard VGA driver and the controls show more responsive.¬† Some other “Vista-like” candies like 3D window / desktop switching are also there.

No operating system is useful without applications. Kubuntu has two package managers, which seem very developer friendly. I could install Apache Maven, Sun Java SDK and Subversion and Eclipse with no effort, I have just queried the package database. This was _much_ easier than doing it under Windows, under normal circumstances.

So for a Java developer I think Linux is a better choice because of:

– zero cost of the operating system

– easy to install all the needed tools

– availability of major IDEs (Eclipse or Netbeans)

– availability of server applications (most if not all of the J2EE servers run on Linux as well)

– database servers available – Oracle, MySQL, Postgresql

Of course, there are also reasons to use Windows:

– Microsoft SQL Server, runs on Windows only

– .Net platform (this belongs actually to .net developers)

– you have hardware which does not works under Linux

So my conclusion are:

– installing Linux is faster then installing Windows

– installing Linux is more difficult than installing Windows, if you are unlucky with the hardware. If you are really unlucky with the hardware or simply not skilled enough, you may have no chance to make it run.

– installing developer tools is much easier and faster under Linux

GWT and J2EE

April 21, 2008

My quest after a consistent AJAX interface continues with the next stop, GWT. It sounds impressive that I only have to code Java, and the client will be compiled in static HTML and JavaScript by the GWT compiler. It provides the complete platform independence. Once compiled, the web pages can be used within any web server.

What about the client server communication? Is this a step back to the static content? Standard GWT provides mechanisms of calling a servlet, with  given classes, which have to implement a proprietary GWT serialization interface. Further researches revealed GWT-EXT, here are even MVC GUI controls available.

So once the client-server communication layer is implemented, development of enterprise J2EE applications can be accomplished quite fast. A closed source application, gwt-plus, with a cost of about $200/year provides a transparent way of working with the beans and collection of beans on the server side over the GWT RPC from the GWT client.

EJB3 Remote client: Hello world vs production usage

April 17, 2008

Yesterday I have made the first remote client for an Session bean. Hello world bean worked great, with a little research about how to configure the JNDI client to connect to the Glassfish server and what to provide in the CLASSPATH. I had to duplicate the remote interface and to delete the EJB annotation, since these JARs shouldn’t be imported on the client. I won’t do it in a production application, so I am ready for J2EE dependencies on the client as well.

The evil is as usual in detail. I don’t use EJB to write Hello word software. My session beans work with complex objects, persisted as entities. The beans do refer another beans, in one-to-many relations. In order to load such a list, the client needs to depend on the persistence library of the server, since that list is not a “vanilla” java.util.HashSet class, but one from TopLink or Hibernate, depending on the chosen EJB persistence.

So, near the entity beans, I had to import also the TopLink libraries in the client.

A solution to move from this dependency forest would be to employ web services. Regarding them, my experiences were not encouraging: they crash when receiving a reflexive reference (object A references object B and B references A) and they suffer performance issues both on server and client side when serving large collections.

Another ideas, is to use the value object pattern. This would mean at least duplication of my data model; but remember, I use MDA, so my model is generated from an UML model. Maybe the build of some plain objects could provide a special client JAR file (beans and service interfaces) and a copy mechanism from the beans, to be used on server side.

Ajax and J2EE or how simple things became complicated

April 15, 2008

Last days I have started a new project. It’s about finance, budgeting and management. The UML class diagrams have already dozen of entities, which translate in dozen of tables.

As a big fan of MDA, after designing the model I have immediately generated the database structure, Hibernate POJOs and EJB (at that moment, still undecided which direction should be followed). The whole work took about 30 minutes, with Apache Maven and AndroMDA.

But what about the user interface? AndroMDA offers something similar to “scaffolding” of Ruby on Rails. My problem with this scaffolding is that a number of files are only generated once, subsequent changes will not reflect them self on the existing generated sources. With other words, it sucks, since I am sure my model is not final, customers will perform lots of changes until it goes into production.

Following the speculation path (yes, I do use Agile PM), I have taken the simplest entity, which only has three columns (2 strings and a boolean) and attempted to see how easy is to have an AJAX based table to perform CRUD (create read update delete) on this table.

The first choice would be ZK, an open source AJAX library. Because of their GPL license, which forces me either to publish my sources or to acquire their commercial license, I have considered another AJAX engine, RichFaces.

RichFaces has a nice comprehensive demo and a bad written manual; as a beginner in RichFace, I find it unreadable because of cyclical definitions (such as: “bypassUpdates attribute allows to bypass the Update Model phase” and no definition of Update Model is given) and employment of too many undefined concepts. Maybe my further contacts with RichFaces will allow me to read their manual with other eyes. I have found a nice sample explaining tables with editable cells. It looks nice, but, it doesn’t store the changed data! The inquiry on the RichFaces forum had was immediately answered by some more advanced user, which acknowledged the issue and provided a solution. I was just one step away of abandoning the RichFaces track and moving to other AJAX engine, but their vibrant community convinced me indirectly not to switch.

After successfully building and running the web application within Maven, my approach is to connect the table to a list of EJB3 entities. The plan is to build a transaction on each change since it is not usual that users will perform a lot of changes here, and this avoids the usage of a “Commit” button people can forget to press while jumping to another page.
I also plan to have a “New Item” and “Delete Item” button. Delete seems to be easy to implement, while adding a new item can be a pain – since the table has a paged scroller and after adding the new item, the scroller should jump at its page. Also, the newly inserted item has an “uncommitted” state until all of its items are filled with data.

Well, after reviewing the findings in this loop, I remember 18 years old technology named “FoxPro”. This technology powered my first business. It didn’t have funny programming features such objects, no enterprise capabilities (they were added afterwards). It doesn’t run through a web interface or even within a windowing system (but on a 80×25 character screen). This tool could easily handle an editor with millions of entries on an Intel 80286 processor based machine, and this with a simple BROWSE command. Now, I read blogs of ajaxians complaining about performance of Ajax tables containing 500 entries! If FoxPro would be hypothetically transformed in a client server engine, considering an average refresh rate of the screen to one second, it would use only a 32kbit bandwidth to run through a terminal. An ajax application uses much more bandwidth, even in the context Ajax reduces the amount of data transacted (and if properly coded, the number of transactions) between server and client.

So, what is the direction our technology evolution follows? Do we sacrifice the simplicity of design and implied simplicity of deployment and usability to acquire some obscure targets such as “transactionability” or “service oriented architecture”? I see now more than ever web sites crashing with errors like “Invalid Transactional State” or “Session Expired” (although I didn’t time it out). I try to imagine what platform did the developers of these sites use and what mistake they done and the answer is from day to day harder to find.