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.
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
Full
Abbreviated
Hidden
Loading... please wait.
Gee, what a deal! (Score:5, Informative)
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.
Parent
Ivory Tower? (Score:2)
The Difference Between Theory and Practice (Score:5, Insightful)
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.
Re: (Score:2, Insightful)
Sorry couldn't resist.
Re: (Score:2)
-matthew
Re: (Score:2)
Re: (Score:2, Informative)
XMLEncoder/XMLDecoder (Score:5, Informative)
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: (Score:2)
I've run into issues like that with NetBeans in the past, and it was a serious headache - I never tried the technique you mention.
My biggest issue with Java GUI development, however, is that there is no common codebase for it - if I write a project with Borland JBuilder or whatever, I have to totally redo the GUI in NetBeans or Eclipse. At least, this has been true in my experience with Borland (which was short and negative). Xcode also has this issue.
Can we get something more lik
Re:XMLEncoder/XMLDecoder (Score:5, Informative)
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.
Parent
Re: (Score:2)
-WS
Re: (Score:2)
Sort of. In my case, I serialized a running GUI to get the file. I could have hand coded it, but that would have been a pain. Instead, I created it in Netbeans, and ran the class through java.bean.XMLEncoder.
Again, the REAL problem is attaching the actions. (i.e. events, keymappings, etc.) If you think about it, you can't attach an event listener inside an XML file, because the XML file is decoupled from your code. S
Re: (Score:2, Informative)
XStream (Score:2, Insightful)
I use XStream [codehaus.org] which is very nice xml serialization utility library. XStream has very nice aliasing abilities, so you can trim the xml to very close to absolute minimum ( 2 minute tutorial [codehaus.org]).
Currently I'm planning on externalizing website validation objects as xml so they can be updated more easily and dynamically. It's basically the same thing you describe and I can easily see how it would help with GUI programming. To get around the "attaching actions to the components" problem you can use the MVC design
Re: (Score:3, Informative)
I have played with XStream a bit. It's nice, but it has the disadvantage of (at least when I tried it) not being able to correctly serialize a Swing GUI. The Java Bean libraries are tweaked to understand Swing classes, so they correctly serialize the GUI in nearly all cases. (Minus a few of the fine details I was mentioning.) Deserialization is a minor issue in comparison.
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: (Score:3, Informative)
You've joined the ranks of Mozilla Firebird, and Jetty, the Tads Virtual Machine [drizzle.com] by trying to make a new project with exactly the same name as an already existing, extremely popular project.
How about you rename it to something that isn't taken?
GINAC=>GINAC is not a computer algebra system [ginac.de]
Step #1 of picking a name for any OSS is looking for it on Google.
Re: (Score:2)
Step #1 of naming *anything* is looking it up on Google.
Re:GINAC (Score:5, Funny)
You should just go the extra few feet and call it "Visually Activated GUI Is Not Application Code".
Parent
Huge oversight on Sun's part (Score:4, Insightful)
Is there an accepted good builder now? The article seems to imply this is far from a solved problem. (10 years later!)
Re: (Score:2)
There's Netbeans [netbeans.org] which has a GUI builder. (Which, IMHO, sucks. Or at least did the last time I used it.)
Eclipse [eclipse.org] also has plugins (the Visual Editor) to allow creating GUIs graphically. (Which is, IMHO, worse than Netbeans's.)
So, there are GUI building tools. They just suck. (IMHO, of course.)
Personally I'd like to see something like XUL where the GUI is specified using a markup language. Which is why I started writing one and then never released it.
Re: (Score:3, Informative)
http://www.netbeans.org/kb/articles/matisse.html [netbeans.org]
Re: (Score:2)
Is there an accepted good builder now? The article seems to imply this is far from a solved problem. (10 years later!)
Yes [jformdesigner.com]
It supports many layout models [jformdesigner.com] including the JGoodies FormLayout, which is far superior to the old GridLayout system.
I've been using it for the last few years and it works marvelously.
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.
Parent
Faces in the Crowd (Score:4, Interesting)
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.
Re: (Score:2)
> that can dynamically retrieve classes across the network
> at runtime and safely instantiate them.
It's kind of interesting how this feature conflicts with Java's static typing system. I mean, if you're receiving a bytestream across the network you need to have some sort of way to unmarshal it into objects, and doing that in Java involves a fair bit of casting and exception catching. You see the same sort of issues with XML to object
Re: (Score:2)
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.
Re: (Score:2)
Uhmm.... Matisse sucks. I like netbeans... but I really do hate their GUI builder.
The GroupLayout that they have bundled with it seems to crap out all the time, as previously placed components suddenly go zooming off to one side. or sometimes even out of the bounds of the component entirely, when all I did was add one more component to the parent. The number of headaches this has caused me in the past is enough to make me not even _try_ using it anymore... I now almost always use either gridbaglayout o
Interface Builder (Score:3, Interesting)
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?
Re: (Score:3, Informative)
Re: (Score:2)
Anyway I was right about the French connection Jean-Marie Hullot [rixstep.com] and Bertrand Serlet [wikipedia.org] are the authors. Bertrand worked at Inria in the offices next to mine when I was an engineer at the OSF. It is interesting that Simon Patience is director of Engineering at Apple and also worked in the same office block in downtown Grenoble city. I believe their are others too.
Re: (Score:2)
It did. IB was a steeper learning curve but built nicer looking (at the time)and more robust interfaces. The Visual Studio GUI builder produced some really messy code as I recall - but I haven't used it since 1993.
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.
Apache Velocity (Score:2)
Also one thing that might be worth looking into is Apache's Velocity, templating at a whole new level.
Glade (Score:4, Interesting)
Hand coding GUIs (Score:2)
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
Re: (Score:2)
I think part of my point is view/controller integration, while not ideal, is not that huge a problem, because they are both user interface elements. What's a big problem is the failure to abstract business domain logic. Whether or not you put it in a "model" tier is mere quibbling. It doesn't matter, as long as its not in the UI. Compared to that the gains of decoupling the view and controller are modest.
IntelliJ (Score:2, Informative)
TrollTech's Jambi does this quite nicely (Score:2, Informative)
I have to say, I'm pretty impressed so far.
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
ResEdit (Score:2)
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 tra
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.
Re: (Score:2)
Perhaps not in a legal sense, but it's a hell of a lot easier to reverse engineer.
Re: (Score:2)
Perhaps not in a legal sense, but it's a hell of a lot easier to reverse engineer.
Also, you can check an XML GUI source into an SCM, and then have a chance of merging and diff'ing it, which is impossible with the binary formats (my one serious gripe over interface builder).
Re: (Score:3, Informative)
Re: (Score:2)
Re: (Score:3)
Maybe I'd like drag-and-drop of files or images or custom data.
Maybe I don't care for the cardinal UI sin of having scrolling areas inside other scrolling areas.
Maybe I want a context menu.
Maybe I want something HTML doesn't provide, like a table with selectable rows.
Maybe I don't want to worry about disabling the "Back" button.
Maybe I don't want to worry about a user double-clicking a form submit button.
If UI librarie
Re: (Score:3, Informative)
No thank you, what happens when they sell a couple of copies then go under. I am then stuck with some libraries I cannot modify or upgrade and a application that will have to then be redone from scratch. I don't care how fancy your wiz bang cool ui generator is, if I do not have the code it is definitely not going into my app.
Right on their home page:
"BuoyBuilder(TM) is released as Open Source under the OSL license. Royalty-free, commercial licenses are available for purchase."
http://buoybuilder.com/DownloadData/BuoyBuilder-sr c-1.1.zip [buoybuilder.com]