Skip to content

Groovy With…

…brevity, perhaps?

Too often, I see code like:

Groovy lets us create much neater code:

I find the version with ‘with’ much clearer. It isn’t actually shorter but–much more importantly–the code clearly indicates: “Dear MAINTAINER: this is doing a bunch of things that are related or require a shared context; break this apart at YOUR PERIL.”

It’s not perfect, but it is better than nothing and it’ll do for now…

I put this out there in the hope that a few will discover this ‘new’ statement (the ‘with’ statement is present in algol68, and may even be older), and a few others will recall it…my contribution to a better world ;-)

Tags:

Java Enterprise Edition, JEE, JavaServer Pages, JSP, Tag Libraries, Servlets, Enterprise Java Beans, EJB, Java Messaging Service JMS, BEA Weblogic, JBoss, Application Servers, Spring Framework, Groovy, Grails, Griffon, Seam, Open Source, Service Oriented Architectures, SOA, Java 2 Standard Edition, J2SE