Jun 9 2007

Why Spaghetti is Not Tasty

Jasper Potts, Sun, gave an insightful presentation at JavaOne 2007 on Why Spaghetti is Not Tasty: Architecting Full-Scale Swing Apps. Jasper started the technical session by describing the first typical architecture for a Swing application. The typical first architecture is to pass everything to everybody. The second level of abstraction in a Swing architecture is to use a singleton object that functions as the application’s service/resource finder/locator which provides lookup methods for an implementation of a given interface. For large applications, Jasper recommends using a framework and he recommends Spar. Spar is a Swing Rich Client Platform framework written by Jasper and based on his research on best practices. As Jasper described, Spar is aimed for applications with over 50K lines of code.

Jasper also talked about software modularity, of breaking up an application down into manageable chunks. Classes, packages, and libraries provide modularity in Java but Jasper, and many other people here at JavaOne, is talking about allowing for modular plugins for extending a given application. such as Eclipse’s plugins of NetBeans’ modules. There are currently a few specification regarding modularity such as OSGi and JSR 291: Dynamic Component Support for Java SE. Jasper recommended several implementations, in particularly Eclipse Equinox and Knopflerfish. Additional JSRs along these lines also include JSR 277: Java Module System and JSR 294: Improve Modularity Support in Java. These JSRs intend to provide a superpackage modular system at the language level. A module helps to separate public API from its implementation, not every class should be visible to the whole application and the visibility identifier can only do so much.

Jasper also made another recommendation that would clean up your code from inner classes. As described by Jasper, a typical Swing application uses the communication pattern typically used by listener classes, which inevitable produce huge interconnections across the whole application and a ton of inner classes littered in the source code. The solution solution recommended by Jasper is to use a message bus for Swing events. This allows the developer to set message rate limit.

The key advice given from Jasper is to break up an application into modules, limit direct coupling, and employ best practices such as plugins, IoC, and event message bus frameworks for developing your next Swing application.

Technorati Tags: , , , , , , , ,


Jun 8 2007

JavaFX Script

This JavaOne 2007 session was originally titled Form Follows Function (F3), after the code name for what was marketed as JavaFX Script. JavaFX Script (JFX) has been one of the most hyped up technology announcements here at JavaOne. According to the marketing literature from Sun, JavaFX Script is a “highly productive scripting language that enables content developer to leverage blah blah …” What Sun PR means to say is that JavaFX Script is Sun’s too little and perhaps too late response to Microsoft Silverlight and Adobe Flex/Flash.

In a eat your own dog food sort of demo, Chris Oliver presented his presentation slides on a PDF viewer application he created using JFX. The PDF viewer demo had great zoom support and even thumbnails of the PDF documents with reflection. JavaFX Script have me at hello, world.

As Chris described, he started working on what eventually became JFX because he wanted to provide an answer to the following set of questions, Why does it take so long to write GUI applications? How do you avoid the “Ugly Java GUI” stereotype? Why is it easier to write a web application than a Swing application? Why don’t Swing programmers use fancy images, graphics, effects, and animations like the Web 2.0 designers?

JavaFX Script is a new programming language that runs on the Java VM. JFX is an object-oriented language with declarative syntax, data binding, and statically type with type inference. JFX allows for custom painting, transformation, grouping, transparencies, effects, clippings and animation. JFX allows you to read and write images. It seemed to me that SVG can do just about the same thing that JavaFX Script intends to do. JavaFX also reminded me of what the Processing project.

As mentioned SVG, Silverlight, OpenLazlo, and Flex provide similar functionality and effects but they introduce a mix of XML-based markup and some degenerate scripting language. SVG is declarative like JFX but Chris doesn’t like the JavaScript/DOM programming model. Chris stated that he rather use a real programming language and a programming model that software engineers understand. The folks behind JFX intend to provide full language support such as refactoring, code completion, code search, code high lighting in NetBeans. In addition to static type efficient compilation JFX provides compile time error and warnings.

Technorati Tags: , , , , , ,


Jun 5 2007

Technical Overview of GlassFish v2

This was the third and last JavaOne 2007 session that I attended that dealt about the GlassFish Application Server. This was a technical overview of what’s new the latest release of GlassFish. The new features in v2 include clustering support, high availability (five nines or that is 99.999), memory replication, and Java business integration just to name a few.

Just as a community service announcement, if you attend a technical session and the speaker starts off by saying, “I have been heads down on this feature…” you should walk out. Anybody that is head down for a year on some feature will surely bore you to death if you ask him about it, even if just in passing. Well this guy I am talking about went into how GlassFish uses JXTA, peer-to-peer technology, to achieve memory replication.

The latest release of GlassFish also has a server usage profiling tool, new administration console, performance enhancements, lazy loading of providers/containers such as EJB, JMS, and HTTP. It is makes good use of the Grizzly project.

Technorati Tags: , , , ,


Jun 5 2007

Being Productive with Swing

Ben Galbraith, founding blogger at Ajaxian, gave an insightful presentation at JavaOne 2007 on Swing. Ben started off by saying that Swing isn’t in the ‘Wow’ game like WPF, Cocoa, or Flex/Apollo. According to him, JavaFX Script might fill that gap but not just yet. In software development, productivity is king. Productivity is the currency of IT development. According to Ben, the Swing Application Framework does not address productivity but instead focuses on basic architectural concerns.

A theme that I picked up from Ben was that there is too much freedom when working with Swing and everybody builds GUIs in their own fashion. Since there is no consistency in UI development even within a project and since there is no solidified framework, Swing applications are hard to maintain and support.

Basically, there is no opinionated software in Swing to provide a standard, convention over configuration, pattern for building Swing-based applications. The key concerns a Swing framework needs to address are data binding, actions, listeners, activation, consistent form, and life cycle events amongst others.

One invaluable recommendation made by Ben is to use the JGoodies Forms layout if you hand code your UIs. Otherwise stick with your favorite UI Builder. He recommended the UI builder over fidgeting with UI code by hand. He said that coding a UI by hand is like hand writing a 50 page TPS report. He also reminded the audience to not muck or edit generated UI code. Ben said to let the UI builder own the code.

Ben recommended JForm Designer as an excellent commercial GUI builder and NetBeans as an Open Source alternative. Without a UI builder, it is difficult to attain UI consistency while fudging with spacers, fonts, insets, etc. Having a framework helps to attain a consistent layout for you desktop application.

Ben also had time to mention his framework, Swing Clarity. Clarity is a Swing Rich Client Platform that borrows heavily from Ben’s experience as a Ajax/web developer. Clarity has a Prototype-like method, $(), which can find named UI components using CSS-like selectors. With Clarity you can bind behavior to components by the variable name of the component with the help of custom @FormUIField annotation. I will definitely look into this framework as it introduces some ideas that make web development exciting. Clarity also provides bi-directional data binding and allows for some amount of skinning.

As an interesting side note, Ben called Karten Lentzsch, JGoodies project lead, the God father of Swing experts.

Technorati Tags: , , , , , , , ,


Jun 5 2007

JavaOne 2007: Thursday General Session

Padmasree Warrior, Motorola Executive Vice President and Chief Technology Officer, gave the Thursday general session at JavaOne. As you can imagine, her theme was the mobile network. In a presentation entitled Platform Disturbia she stated that in the mobile device world each network, each device, each spacial domain is its own platform. She also presented some figures where she states the there are more cell phone devices than cars, or televisions, or any other electronic consumer good. Padmasree enthusiastically said, “The whole world is a hot spot.”

Padmasree had a quick panel discussion regarding which mobile technology will win, mobile AJAX vs J2ME. The panel discussion was with mobile tech writers and pundits AJit Jaokar and C. Enrique Ortiz. In the end, I think it was Enrique that said that both have their strengths and weaknesses. To me, the debate sounded a lot like the same one between the desktop and web applications.

One thing that Padmasree said that stuck with me was that software development is about the user experience not the user interface. Sometimes as engineers we do over think a solution. We often design a system which ends up looking and behaving like it was designed by a software engineer, not a real person.

Motorola also took the time to promote their Open Source initiatives and their Developer Studio.

Technorati Tags: , , , , ,


Jun 3 2007

Putting a Swing Front End on a Web Application

During this JavaOne 2007 BOF, David Wroton shared his experienced of porting a JavaServer Faces (JSF) front-end to a Swing desktop client. David started with the whole browser vs fat client debate. David listed his issues with the browser, such as HTML Scrolling, back button, Funky JSF URLs. He said that “the back button is something that is breaking society.” The benefit of developing a HTML web application is that it is easier to get started.

The issues listed by David as holding back a rich Swing desktop include installation, maintenance, and getting started from scratch. To work around installation issues David used Java Web Start and instead of writing the desktop client from scratch he looked into using a Rich Client Platform such as Eclipe, NetBeans or Spring. Regarding the choice for which RCP to use he said, “There was a review last year, the review said, man, they are all hard.” Ultimately he selected Spring RCP, mostly because of his previous exposure to Spring. According to the speaker, Spring RCP has good form, data binding, and validation support. The major draw back to Spring RCP is the lack of documentation, an issue descried in last years’ review of Rich Client Platforms.

In closing, the David told the audience that the desktop is far more rich than any web based application, but AJAX goes a long way making a web application more user friendly and for many applications that is enough. Finally, he said there are still no clear lightweight/agile solution for a Swing framework.

Technorati Tags: , , , , ,