Groovy Java SE Project Postmortem

Thursday, October 16th, 2008

I recently finished up a 10 month project for the City of Chicago’s budget office. Below is a transcript of the project postmortem interview with me as conducted by my 4 year old daughter, Meredith.

—————————————

Meredith: Hi daddy, how was your work?

Me: It was good, thanks for asking. We’ve recently finished primary development on our application and released it to production. The application, as you know, was a Java Swing desktop application that produced the City’s budget book. It replaced an older mainframe app.

In fact, here’s the output of the final book if you’re interested. It may not seem like that big of a deal, but compare it to the previous year. Besides the obvious visual upgrade, it used to take over three hours to produce a book, and even then the hardcopy had to be scanned back into the computer to obtain the final PDF. That entire process has been reduced to a few minutes.

One might think that this was just a Jasper Report, or perhaps produced by iReport.  While iReport is no doubt very good at producing generalized reports, we needed something that gave us a real-time look at the book before it was fully constructed and allowed for non-rule based changes.

So one of the things the application does is provide an “editor view” where the user can put in hard page breaks anywhere, or insert styled text in between arbitrary rows and then immediately preview the changes as a PDF.  In other words, the application needed to automatically generate this 600 page document, but allow the user to arbitrarily customize it as it was being built.

Meredith: Do you work in the bunny ears building? [The Sears Tower - ed.]

Me: No, the project was in City Hall, which is several blocks away.

Meredith: Do you like your work?

Me: Yes, I found the project rewarding.  We were given “carte blanche” with the design, so we were able to include some neat technologies.  For example, iReport/Jasper uses xml files to define how a report will look, but we used Groovy to accomplish the same thing.  You see this sort of migration from XML to dynamic languages elsewhere as well.  For example, Gant is like Ant, but with groovy scripts instead of XML.

Anyway, so we were able to include a Groovy scripting layer which we used to create a DSL of sorts to define the application’s output. The DSL in this case was the Chicago Budget System’s lingo. So Groovy was able to understand Organizations, Funds, and Departments as if it were built into the language’s syntax.

The other side of the DSL was the language of the book itself, that is sections, elements, styles, and page breaks.  Using this syntax then we could define the structure of the final output of the book. This was especially helpful for the budget office’s internal IT staff, who were obviously intimately familiar with the budget terminology, and will be maintaining the application going forward.

We also used Hibernate in the data access layer, which in a desktop application may be a bit unusual.  When most people think of Hibernate, they likely think of web apps, but then when you say almost anything most people probably think of web apps. (chuckles)

Meredith: (laughs) (snorts) Daddy! That’s silly!

Me: Seriously though, I think there were some challenges to fit certain technologies into a context they weren’t originally designed for.  In the case of Hibernate, you know, Hibernate seems to be modeled around this idea of “unit of work”, which fits nicely into the request/response cycle of a web app, but in a “always connected” desktop app, that model didn’t quite fit. So we had to futz with things a bit until Hibernate would play nicely with our app.

Meredith: In school, today, um, Charlotte, she, Charlotte wanted to play with the doll that I was playing with, and Miss Erin said that we should take turns, and Charlotte didn’t want to take turns.

Me: We also used several very new technologies, like Sun’s PDF Renderer, for an “on demand” PDF preview.  On the UI side, we used several SwingX components (from SwingLabs) as well as the Swing Application Framework. The SAF was (and still is) very new, and…untested. It did a good job at dealing with some of the thankless parts of desktop application development, such as managing resource bundles, application lifecycle, and task management. It was a bit raw, but I think it has a nice future at providing an alternative to heavy RCP solutions such as Eclipse and Netbeans.

Meredith: And then Kevin just wanted to play shooters, but I didn’t want to play shooters so Emily and me, we played Fairy Princess Castle.

Me: You talk about Kevin a lot. Is he your boyfriend or something?

Meredith: NO!!!  Daddy!!

Me: Whatever, you’re totally going to marry Kevin someday. So anyway, as far as desktop apps go–

Meredith: Hold up. Did you say this was a desktop application?

Me: Yes…

Meredith: Not a webapp? What’s the problem? Are you afraid of AJAX or something?

Me: What?! No! In this case a webapp was not appropriate. We had complete control over the user’s machines for deployment and the application required some very responsive rendering that Java2D was able to provide.

Meredith: As your dependent I feel compelled to advise you to perhaps, you know, invest in some marketable skills. I mean, how are you going to pay for my college? Maybe you should get some Flex training or something.

Me: I have marketable skills! Java is everywhere — not just on the web. Since when did the web browser become the only important application context?

Meredith: 1997

Me: Well if you love the web so much, why don’t you just marry it then?!

Meredith: I thought you said I was going to marry Kevin.

Me: This interview is over!

Tags: , , ,

5 Responses to “Groovy Java SE Project Postmortem”

  1. Matt Campbell wrote:
    October 16th, 2008 at 11:02 pm |

    Sten, this is either the work of a genius with a clever sense of humor or the rants of an insane madman.

    P.S. You probably could have caught Meredith off guard if you pointed out that she was -7 in 1997.

  2. Guillaume Laforge wrote:
    October 17th, 2008 at 2:51 am |

    Awesome and funny blog post, thanks a lot.
    I’d be curious to learn more from your Groovy DSL!

  3. sanderson wrote:
    October 17th, 2008 at 8:44 am |

    Hi Guillaume, thanks for stopping by! You can read a bit more about this specific DSL at this post: http://blogs.citytechinc.com/sanderson/?p=10.

    I’d be happy to blog more about this topic if there is interest.

    Matt — It turns out that Meredith is a voracious reader of the history of software design and analysis trends.

  4. Sten’s Blog » Blog Archive » The Map vs. the Terrain (or DSLs as Documentation) wrote:
    December 12th, 2008 at 12:43 am |

    [...] my most recent project, we used an internal DSL, partly for ease of development, but also, as a nice side-effect, for its [...]

  5. Sten’s Blog » Blog Archive » First Ever Chicago Groovy User Group wrote:
    January 11th, 2009 at 4:04 pm |

    [...] I’ll be giving a talk on integrating Groovy DSLs into Java applications, focusing specifically on a project that I’ve recently finished. [...]

Leave a Reply