Posted by eitan
on October 21, 2003 at 8:01 AM PDT
When starting a new project, the User Interface decision is always a big one. Should we use Swing? Or should we develop a web-based solution?
When starting a new project, the User Interface decision is always a big one. Should we use Swing? Or should we develop a web-based solution? Some also are correct to argue that web-based doesn't necessarily imply HTML-based. Macromedia-based web solutions are not only viable but a real player. In certain circumstances, the requirements make the choice fairly clear, possibly even mandated.
The traditional trade-off, whether true or not, has always been along the lines of: "give up richness of the UI that comes with Swing for a rapid development cycle that is the web." Developing UIs in Swing does seem to require more skill, knowledge and experience with a very large API. It didn't use to be so with HTML but new standards have crept up over time: CSS for styling, various XML technologies for keeping content away from presentation (XSLT perhaps, now XQuery is on the horizon). But developing web-based solutions also implies knowledge of relatively new frameworks such as Struts or Tapestry, maybe Cocoon. For Struts, one also has to be familiar with underlying technologies such as JSP, Taglibs. JSF is now the newcomer and JSTL has surfaced. So does the web way really look like a "piece of cake?"
Some have argued (and I agree with them) that a tremendous effort has built layers of abstraction on top of the HTTP protocol to make the web a platform for building distributed applications. Their point is that the web was never intended to be such a platform. From this angle, it almost feels wrong to try to "shoehorn" the web for web app development.
Traditional developers sometimes are offended when they see web-based apps violate principles that they would never even consider bending: having to make repeated calls to the server to get back the same information over and over again: headers, footers, markup that could easily be cached otherwise (that is if Swing were used instead of a web browser).
I very much enjoyed reading Amy Fowler's article on JDNC (Java Desktop Network Components) on JavaDesktop.org. Amy's article clearly sums up the debate between web'ers and swing'ers. JDNC hopefully will narrow the gap some more.
It's interesting to analyze how "the gap" has narrowed thanks to various technologies introduced in both camps to help them overcome their weaknesses. On the swing side, there's a lot to talk about: we've had Java Web Start for a while now and people are using it more and more. Also, I really like the frameworks that have embraced a pattern which is admittedly a good one used in the web world: that of using markup to define the layout of a user interface. Allen Holub's recent JavaWorld article on HTMLPane shows how one can make use of this pattern in Swing applications. In my mind the kudos should go to the folks who are building frameworks such as Thinlets (www.thinlet.com ), and XUL. They're taking the idea to an entirely new level.
Now here's the one that I think takes the cake: NakedObjects (NO). This framework looks at things clearly, and from a perspective that I believe has almost been entirely overlooked by most. The idea is simple: don't waste your time writing user interface code. It's the same thing over and over again. Instead, use a framework that will draw the User Interface on your behalf; you just concentrate on your business logic, what you're supposed to be doing anyway! :) I have to admit the NO folks have a point. If you haven't done so, I recommend reading Richard Pawson's and Robert Matthews' book "Naked Objects" (http://www.nakedobjects.org/book.html ). Yes, I agree that today there do not exist very many NO-like frameworks. NO is a terrific tool for prototyping applications. It's the only way to go for prototyping. One can so quickly develop a prototype application that can be placed in front of a customer, facilitating communications and feedback with the customer.
NakedObjects and various related development efforts today can take the same business logic and give you a user interface in AWT, Swing or DHTML. That said, the Swing version is 0.4, the DHTML version is also somewhat experimental. But it proves the point. I believe NO is a glimpse of things to come and sincerely hope that within 10 years the idea of painstakingly crafting user interfaces by hand will be a thing of the past.