Slashdot Log In
Resource-Based GUIs Vs. Code Generators In Java
Posted by
kdawson
on Thu Nov 30, 2006 10:48 AM
from the gooey-java dept.
from the gooey-java dept.
Java Fan writes, "There is a good debate about GUI generation tools for Java going on at theserverside.com: 'Almost every platform has a visual designer that serializes the GUI to resources (some XML, some proprietary binaries) and then attaches it to the controller at runtime. Apple has had this for years with Interface Builder, Vista has a similar philosophy now as well. Java developers though are left with either hand coding of GUIs or potentially messy and brittle code generators. Neither of which promote good MVC separation. In fact they tend to encourage violations unless you are a very disciplined coder.' Personally, I am partial to BuoyBuilder as a great solution to this issue."
This discussion has been archived.
No new comments can be posted.
Resource-Based GUIs Vs. Code Generators In Java
|
Log In/Create an Account
| Top
| 164 comments
| Search Discussion
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
Gee, what a deal! (Score:5, Informative)
(http://www.luminance.org/ | Last Journal: Wednesday April 24 2002, @05:35PM)
Wait, no, sorry. It's not.
Nice slashvertisement.
Re:Gee, what a deal! (Score:4, Insightful)
That's the ivory tower answer, and from a certain perspective it's true and from a certain perspective it's not.
The last Java shop I worked in wouldn't pay for any development tools. Good tools that were free (as in beer) or close to it were at a premium.
The Difference Between Theory and Practice (Score:5, Insightful)
(http://www.transitio...gi-bin/articlerss.pl | Last Journal: Wednesday June 01 2005, @12:45PM)
In theory, I'm not against the use of a GUI builder as long as it provides a way to use all of the layout managers that are available. I've just never seen one that could scale in complexity to the needs of a real world application. Sooner or later, the functionality requirements drive GUI elements to be created based on configuration settings and/or business rules. That is where you hit the wall with the GUI builder.
XMLEncoder/XMLDecoder (Score:5, Informative)
(http://www.intelligentblogger.com/ | Last Journal: Monday August 27, @11:47AM)
Anyone who's interested in this issue should look into the java.bean.XMLEncoder [sun.com] and java.bean.XMLDecoder [sun.com] classes. These classes are able to serialize and deserialize complete GUIs. In the past, I've used the Netbeans GUI Builder to develop throw-away GUI frontends, then serialized them to a file rather than using them directly. I then built a framework that used the little-known "Name" property on AWT/Swing components to attach actions.
The results were quite good. Not only was the GUI decoupled from the code, but development was actually accelerated as minor GUI hiccups had no effect on the rest of the codebase. The downside was that the XML occasionally had to be tweaked to perfection as the XMLEncoder class was not 100% perfect in serializing some of the finer details.
A few years ago I spoke with one of the Netbeans developers about making the XMLEncoder format the standard for Netbeans. The idea was met with some resistence, seemingly because there was no actual Java-standard framework to target. The JVM base libraries have the Encoder/Decoder routines, but all the rest of the work must be done by the programmer. (Such as attaching the actions to the components.)
Train yourself to use Swing Actions. It seems like you're creating hundreds of little objects, but what you're really doing is encapsulating actual actions in the system away from their physcial controls on screen. So if you have a button, a menu item, and a toolbar item that all do the same thing, a single action can control all three widgets. This helps smooth out issues like keyboard shortcuts, which can get quite confusing when coding a Swing application.
Re:XMLEncoder/XMLDecoder (Score:5, Informative)
(http://www.intelligentblogger.com/ | Last Journal: Monday August 27, @11:47AM)
The problem isn't the toolkit. It's the lack of a standard serialized form. In the Windows world, the standard format is known as a "resource file". Since all GUI editors target this resource format, there is no compatibility issues across IDEs. Similarly, GTK+ standardizes on GladeXML from the Glade Interface Designer [wikipedia.org]. So there's no question about what format an IDE should support when adding a GUI Designer.
Swing is one of the few GUI technologies that doesn't have a standard serialized format. The XMLEncoder technology took a step toward solving this, but didn't follow through. The result was that we had a format, but no library to actually wire up a deserialized GUI! (e.g. GladeXML is decoded by libglade) This oversight was rather massive, but ended up being ignored as the focus continued to shift toward server-size J2EE development.
GINAC (Score:4, Interesting)
We started a project along the lines of Interface Builder with a Java Swing implementation for our master's thesis in 2005. It's called GINAC, as in GUI Is Not Application Code [ugent.be].
As I really hate designing GUI's in code, I've started working on it again lately, currently implementing something along the lines of cocoa bindings. If anybody is interested in helping out, let me know!
Re:GINAC (Score:5, Funny)
You should just go the extra few feet and call it "Visually Activated GUI Is Not Application Code".
Huge oversight on Sun's part (Score:4, Insightful)
(http://www.xdesignlabs.com/)
Is there an accepted good builder now? The article seems to imply this is far from a solved problem. (10 years later!)
Re:Huge oversight on Sun's part (Score:5, Interesting)
I'm guessing you really mean GridBagLayout, since GridLayout is a different and very very simple layout.
I realize GridBagLayout is hard to learn, but over the years I've learned that you cannot avoid it.
Sun has tried [sun.com] three [sun.com] times [sun.com] to make a "simple" replacement for GridBagLayout. Each attempt utterly fails as a replacement (but each is useful for some other rare types of layout needs).
I've tried to make my own "simplified" version of GridBagLayout too. In fact, I suspect nearly every intermediate Java GUI programmer tries this at some point; it's almost a rite of passage. And it's always a failure. The reason is that UI layout simply is that complicated, and there's no way around it. If you think it's simpler, then you probably aren't aware of all the issues involved.
A UI builder won't make it any simpler. It will just make it easier for you to ignore the issues. The usual result of such "freedom" is that the resulting UI looks acceptable, but doesn't have acceptable behavior. For instance, to pick a simple case, a scrolling list doesn't resize when the window containing it resizes.
Faces in the Crowd (Score:4, Interesting)
(http://slashdot.org/~Doc%20Ruby/journal | Last Journal: Thursday March 31 2005, @01:48PM)
If those APIs don't already exist, reusing an existing one, especially Flash, would offer possibilities for reusing existing components or patterns already populating the Net.
Java could increase its stature among distributed architectures. And make our lives easier.
Never heard of Matisse eh ? (Score:5, Informative)
Whenever it comes to Java it always amazes me how many people have very outspoken opinions about it while its almost immediatly obvious that they hardly know what they're talking about. Then again, when reading the article its becoming obvious that when he's talking about GUI's (since when do you code in a GUI? I use an IDE for that) he actually means to say Eclipse. Don't get me wrong: I'm not dissing Eclipse here, but do question his bias.
When it comes to building GUI's Java really allows itself to be used by code generators IMO simply because Java is very modulair build. The only problem you might face here are the somewhat limited layout managers. For the non-Java people amongst us: these basicly define the "interface" between the GUI you're building and the way it behaves. For example; when it comes to resizing or placing of the objects then you're dealing with a layout manager.
Now... When it comes to Java IDE's two names immediatly spring out: NetBeans [netbeans.org] (my personal favorite) and Eclipse. Now that he has commented on the latter let me comment on the first. From NetBeans 5.0 and up it comes with a fancy GUI builder codenamed "Project Matisse". Its official name is now NetBeans Swing GUI builder [netbeans.org]. After taking a closer look at that I wonder if he still thinks that there are no decent GUI builders available for Java.
The real problem here isn't so much the GUI builder but the underlying layout manager which needs to keep things in check. I think that also explains why there isn't much of this available as it looks to me as if there aren't many people about who manage to come up with decent Java coded tools which can be used and adopted by many other coders. NetBeans has solved all this by introducing a layout manager of their own, the so called Absolute Layout. Pro's are its extreme extensiveness, the con's are that if you wish to use it you'll have to ship it with your software because its not part of the standard Java Runtime Environment (JRE).
If you wish to see a demo of Matisse in action then check out the NetBeans flash demos [netbeans.org], especially the first part of "Why NetBeans?". Personally I'd recommend another approach, namely simply downloading NetBeans [netbeans.info] and trying it out for yourself. Its available for Linux, Solaris, Windows and I think even OS X.
Interface Builder (Score:3, Interesting)
(http://www.abcseo.com/)
Presumably NeXT has had it for even longer, a couple of decades or there abouts. IB was written by a brilliant French coder as I recall... he was a friend of a colleague. Short of firing up my NeXTBox does anyone remember more of the history?
Hybrid approach for fast dev - good code (Score:1)
My approach is to use the GUI designers to quickly prototype the UI and for fast proof of concept. Once I am pretty close to the requirements, it is time to refactor to good coding standards.
With regard to Java, the only approach that I have seen that is flexible and maintainable is to provide the correct getters/setters for Introspection (e.g. a JavaBean) so that your GUI Widget can be manipulated by a Visual designer for future use in other UI's and for maintenance.
Just Use Swing (Score:3, Insightful)
I can understand why people think they need XML-based systems. So much Swing-based code sucks ass. Putting all of your buttons and frames in a big-ass method is nasty and hard to maintain. Well-thought-out componentized Swing code is easy to maintain and nice to look at. Plus, once you are finished with your project, you can re-use any components you built. Swing is a great library - more people need to just learn it.
IBM's AUIML (Score:1, Interesting)
Apache Velocity (Score:2)
(http://www.redcode.nl/)
Also one thing that might be worth looking into is Apache's Velocity, templating at a whole new level.
Glade (Score:4, Interesting)
(http://www.mozilla.org/)
Hand coding GUIs (Score:2)
(http://kamthaka.blogspot.com/ | Last Journal: Wednesday March 30 2005, @03:18PM)
Hand coding may not promote a clean separation of concerns, but it does nothing to preclude it. Interface generation does not ensure a clean separation of concerns. In fact I doubt that it does anything significant to promote it.
The problem is that the controller tier is still a user interface component, which many engineers don't seem to understand. The achilles heel in most MVC programs are bloated, unmaintainable controllers. You still end up with important assumptions being spread hither in yon in user interface code. The fact that it is non-visual interface code makes no difference at all. What you end up is not, fundamentally, different from the typical VB program, but often minus the convenience of tying UI elements to event handlers in the IDE.
There's nothing wrong with the MVC pattern, but there is cargo cult that has grown up around it, spurred by the impedance mismatch between browser presentations and server side processing.
You can't force people to do good design by making what the produce resemble a good design.
With respect to XML and other data representations of views, I've dabbled in them, and have not been that impressed. Consider isomorphic view represenations, one in Java and one in XML. Once you've gone through the effort of separating out your contol logic, there isn't much to choose between them. Sure, the XMl is probably language independent. But the Java is trivial, which helps make your code independent of the framework.
IntelliJ (Score:2, Informative)
TrollTech's Jambi does this quite nicely (Score:2, Informative)
(http://jura.wi.mit.edu/people/kelley/)
I have to say, I'm pretty impressed so far.
Who builds GUI's anymore.... (Score:1)
Serializing GUIs is difficult? (Score:2)
Also, it's difficult to get reuse out of a GUI editing tool, but very easy to get it by hand-coding. I generally write factory-type code that handles generating menus, buttons and linked Actions together, in a GUI tool you will often end up having to deal with each of these separately.
Much of the GUI code I've had to deal with is in the form of Properties sheets (large number of controls in predictable patterns). You absolutely should never generate this kind of GUI--or hand code the gui itself for that matter. The entire GUI should be generated from data files.
So in the past, RAD tools for swing were used by more amateur less professional users, and the amateur users are going to feel much more comfortable with generated code. Now that the tools are coming up to the point where professionals are starting to use them, I think we'll see a lot more cases of "Serialize out a finished screen at design time" and "Serialize it back in at runtime". (This was in some of SUN's original Java tools if I remember correctly).
ResEdit (Score:2)
(http://home.earthlink.net/~johnrpenner/)
this system was eminently useful in getting mac applications translated into languages other than english, as any user could open the shipping application with resedit, start translating strings, save a copy of the resource, and start shipping a translated version. if the translated text was longer, and wouldn't fit in the dialogue box -- no problem, you could alter the window dimensions right there, and since the ID of the dialogue box was still the same, everything still worked.
brilliant, that's how good it was in 1984... then came windows, and we lost all that. some of it survived in the NeXT OS, which carried over the 'Interface Builder' paradigm to unix. this is ultimately the source of application frameworks, and the nested folder structure of an
best regards,
j.
Don't use GUI builders (Score:1)
(Last Journal: Friday December 08 2006, @04:42PM)
GUI builders have been around for as long PHB's have wanted to insert themselves into the development process to speed up development. Don't use them. GUI builders relieve the programmer of the easiest, least demanding part of the development process - widget creation and layout. They add overhead and obscure GUI API's. They offer little to better organize interface callbacks into a nicely designed program. In fact the combination of generated and custom code will leave the next guy who has to maintain your program to wonder what you were thinking.
Standard answer: XUL (Score:1)
Nice (Score:1, Insightful)
having trouble digesting this... (Score:3, Insightful)
I don't mean to sound all high and mighty, but if you aren't a disciplined coder, then you're not very serious anyway. You can pre-plan the MVC design to your hearts content, but it takes discipline to stay within the boundaries of the original design. Especially since if you don't then you create one of the worst anti-patterns ever, making you wish you'd just written one monolithic chunk of procedural code because bugs/changes would be doable.
Qt Designer is free (Score:2)
(http://www.pleasantonplayhouse.com/)
What good resource based GUIs are there? (Score:2)
(http://slashdot.org/ | Last Journal: Saturday February 05 2005, @03:50AM)
Maybe using Microsoft's GUI XML format could be a solution? Quite honestly I really think a JSR to make a standard Java GUI resource format would go a long way.
Messy and brittle? What is he talking about? (Score:1, Insightful)
The one problem with Swing is it is capable of doing too much, which makes some of the simple stuff more complicated than it should be. But I can do any kind of visual effect I want to do. Spend a week or two using Matisse and then decide what you think about Swing.
If you haven't used Interface Builder (Score:2, Informative)
In fact, IB should have been named "Object Connector" because it is not a "builder" at all. All IB does is let you instantiate objects, specify their initial state, and define connections or relationships between the objects. You should note that it is equally applicable to user interface objects and every other kind of object including your own custom classes. The configured objects are serialized to either a binary file or an XML file (your choice). The "Test" mode in IB just serializes and then de-serializes the object graph in memory to produce a fully functional system that you can test.
Although Interface Builder has been available since 1988, it is actively developed by Apple and is in fact free along with the rest of Apple's development tools with Mac OS X. Recent additions to Interface Builder have included Key-Value Observing which eliminates al lot of "controller" code from a system and Data Modeler which automates a lot of "model" code.
Steve Jobs used to state that it doesn't matter whether code is hand written or computer written, every line of code is a potential bug and a source for future maintenance. The only way to radically improve programmer and life-cycle productivity is to radically reduce the amount of new code needed to implement applications. IB is a stellar example of the wisdom oh his words. [This is also a huge win for cultural localization...)
Given the extremely rich frameworks of objects (both GUI and non-GUI) that are available from Cocoa, IB's ability to instantiate objects and form connections and relationships between them without any code is a huge win. If you haven't used this technique, trust me: you don't know what you are missing. You will never want to go back!
IB's down side has always been documenting (for posterity) all of the connections and relationships that are specified in IB. IB is improving on that front with XML file formats and data "entity-relationship" modeling built in. There have also been plug-in palettes that improve documentation generation.
Just as a reminder, unlike most GUI builders, IB works equally well with your custom classes and the framework classes. You can build new "palettes" for you objects to provide slick graphical interaction, but the basic connections and relationships capabilities work with all objects with no special effort.
Apple's IB description: http://developer.apple.com/tools/interfacebuilder
There is an excellent but shallow Introduction to Interface Builder at http://developer.apple.com/documentation/Develope
IBM's Rational Application Developer (Score:1)
http://www-306.ibm.com/software/awdtools/develope
I use it for all the coding work I do. It has a GUI building tool that only generates Java code. Its much better than the old visual age line of products that required separate files to manage the GUI construction. You can even edit most of the generated code manually without fear of no longer being able to use the GUI builder. It uses (Eclipse [eclipse.org]) as its base platform so other eclipse plugins can be added to the tool. It includes extensive tools for other web related development as well (DB definitions, EJB work, XML, etc...)
Granted, it's listed as ~$2k for 1 license, so its not for everyone, but you'd be hard pressed to find a java/web development function that it doesn't help you with.
Dan
Foam uses XMLEncoder (Score:1)
The Qt Way (Score:2)
(http://www.usermode.org/ | Last Journal: Tuesday April 17 2007, @09:13PM)
This gives you a lot of flexibility. You can use the UI object directly, as a data member, or through multiple inheritance. You can even load the XML ui file at runtime if you wish, using the QtUiTools library. It also give you a clean OO design, as the UI itself is a stand-alone object.
Re:Proprietary UI Builder (Score:1, Flamebait)
Re:Proprietary UI Builder (Score:1)
Re:Well, when they fix all the bugs in BuoyBuilder (Score:1)
Re:"some XML, some proprietary binaries" (Score:2)
(http://www.livejournal.com/users/pstscrpt)
Perhaps not in a legal sense, but it's a hell of a lot easier to reverse engineer.
Re:Proprietary UI Builder (Score:3, Informative)
(Last Journal: Thursday May 24, @01:08AM)
"BuoyBuilder(TM) is released as Open Source under the OSL license. Royalty-free, commercial licenses are available for purchase."
http://buoybuilder.com/DownloadData/BuoyBuilder-s
Re:code-generators (Score:2)
(http://theravensnest.org/ | Last Journal: Sunday October 07, @07:05AM)
Re:code-generators (Score:2)
And yet, nearly all Java layouts seem to do exactly that. If you don't believe it, arrange some components into a GridBagLayout with at least two columns and look at the results. Then add a call to applyComponentOrientation( ComponentOrientation.RIGHT_TO_LEFT ) on the window (after all components have been added to it), recompile and look at the results again.