« October 2007 | Main | December 2007 »

November 2007 Archives

November 7, 2007

MVC Separation in SwingBuilder Using the build() method

There is actually a GUI related feature in Groovy 1.1-rc-2 that I haven't blogged about yet, and it's a good one. A new method build was added that allows the user to load other Groovy scripts as though they were part of the currently executing script.

Huh? you say. What's so exciting about that? I could go on about how I changed FactoryBuilderSupport to extend Binding instead of GroovyObjectSupport and how I did some MetaClass magic to expose the methods of the builder to the script itself. But that is not what's really important. What is notable is how this enables and facilitates pure MVC separation in Groovy code.

MVC separation? Some may think that this only something web frameworks espoused, mostly because breaking MVC takes more effort that it is worth. However, Swing is notorious for breaking MVC because it is almost more effort that it is worth to do a good clean MVC separation, at the file level.

This is best illustrated by example. Consider one of our examples, the Groovy Regex Coach. It's got fairly good MVC separation to begin with. The existing good MVC separation is why I use it as an example, because when you separate out the view into another file, the controller logic is still sound. The principal difference being that at line 17 all of the view markup has been replaced with the call we use to load the view:

def gui = swing.build(RegexCoachView)

That's a fairly simple example, but more interesting is the changes I was able to do to the Console. The RC cycle is a very bad time to do major refactoring to a user facing component, so I did my experementing in the SwingXBuilder demos area. It's by no means a textbook example of MVC, but it does show off loading the view at the top level (lines 47 and 50) and then calling build() within the context of an existing build (lines 49-55). For extra credit I even used the variant where we compile a script at runtime to deal with MacOS specific classes (lines 59-84).

So yes we here at the Groovy project do eat our own dog food, and if I owned a dog I'd feed him sirloin and pizza too. I wish I was more the master of prose to communicate how big a deal I feel this is, but I'll just say that it is a big deal.

November 22, 2007

Real Life Requrements Analysis

There is a fine line between cynicism and accepting the reality of your clients. Sometimes they exist in superposition. For example. this quote from a use case thread I've been involved with.

I cant really see a reason for [our client] to do this, which means that they will definitely want it.

Happy Thanksgiving

November 26, 2007


Does anyone else see the problem with My NetBeans requiring Flash? Not just requiring flash but running client side 100% Flash! No AJAX? JavaFX? JRuby? A Java IDE that touts itself as the best platform for RIAs dosen't eat it's own Dogfood? and sends advertisements for Apache Flex in the page source?

After nearly seven years as a NetBeans user, I think it's time for me to pony up some cash and switch to IntelliJ.

About November 2007

This page contains all entries posted to ... And They Shall Know Me By My Speling Errors in November 2007. They are listed from oldest to newest.

October 2007 is the previous archive.

December 2007 is the next archive.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type 3.33