XUI: Not Convincing

08/22/2003

Summary: The people who are developing XUI claim a 60% reduction in code when using XUI... however they fail to provide adequate proof. (Note the date above and keep that in mind if you visit XUI's website and the claims have changed.)

If you're going to add an abstraction layer over a subsystem, it better be quite thin and worth the effort to learn. XUI claims a 60% reduction in code size when used vs using AWT natively and claim similar savings with Swing.

I doubt this would be a 60% reduction on the whole code base of a real-world application. It would have to be a 60% reduction of the GUI-related code which itself is only one relatively small portion of a normal application. I did a quick analysis on Exert grepping for files that use javax.swing or java.awt and considering all files that do have that string to be 100% GUI-related and files that don't have that string to be 0% GUI-related: with this method, Exert contains about 17% GUI-related code and that's an overestimate since you can be certain that files that don't use either javax.swing or java.awt are not GUI-related but files that do use javax.swing or java.awt are certainly not doing 100% GUI work. So at best, in the case of Exert, using XUI and assuming the 60% claim is true, that would be a 10% improvement and this is an overestimate. (I'm guessing the actual GUI-related code in Exert, if the analysis was done on a line-by-line basis would be at most 8% so the benefit would be around 5%.)

Then, the problem is that the 60% claim is not backed up by any data from a real-world application. I realize that's no small task but toy projects are just not good enough to substantiate productivity claims. It's just too easy to tailor small projects to make the methodology being sold look good. What is needed is some real project where corners are not going to be cut.

More alarming are the examples actually given on the web site. I'll take one example (quoted from this page):

Although it may not sound like much, a factory method is a great way of reducing the amount of code. Take for example the creation of a simple static piece of text. Typically this would require code such as the following:

JTextField myText = new JTextField();
myText.setForeground( new Color( 255, 0, 0 ));
myText.setText( "Hello World" );
myText.setBounds( 10, 10, 150, 30 );
add( myText );

and even more is required if you wish to set fonts. Using a factory method, this construction code is greatly reduced. Using XUI's factory classes, a single line of code can be used to replace the above.

JTextField myText = (JTextField)myFactory.addComponent( XLABEL, 10, 10, 150, 30 );

Call me stupid but I don't see how the single line of code above replaces all the lines in the first code snippet. The setForeground and setText methods are not covered by the 2nd code fragment so this looks misleading to me. Looking at other examples on the page, which I'm not going to reproduce here, I note similar problems: the code shown to demonstrate how XUI does things doesn't seem to cover the same functionality are the original AWT or Swing code.

Then the example above has another problem: it uses absolute coordinates. The documentation confirms that no layout is in effect: "The factory is designed to create components for a null layout". This is very bad GUI design since if the component is ever resized, the children it contains won't be repositioned and resized appropriately.

So the 60% figure doesn't say 60% of what, certainly not 60% of the whole application, but XUI team fails to demonstrate the 60% figure on 3 counts:

  • no real-world example is given of the 60% figure,
  • the transformations of "code without XUI" to "code with XUI" don't cover all of the original functionality and thus are misleading,
  • using absolute coordinates is a bad design decision: how does XUI fare if layout managers are used?

Note that I'm not saying XUI can't provide some useful functionality (but this also needs to be tested in the real world): only that the 60% figure is not demonstrated.