Thursday, September 28, 2006

Lightweight Java Development with Webwork, Spring, and iBatis

I know the latest buzz in web development is to move toward lighter weight frameworks, or even to move to a dynamic language like Ruby or Python (though Ruby on Rails definitely seems to be attracting more developers than python at the moment. I've actually been researching the 2 languages, but more about that in a later post). However, i think the heaviness of java is often times overstated. Many of the newer java frameworks can help speed your development time, if you choose the right combination.

Our new site, ForGetaway.com, launched 2 weeks ago, and its built on WebWork, Spring, and iBatis. Using those 3 frameworks as the backbone of the site was a great experience. I think that combination of frameworks can be considered lightweight, especially from a development standpoint. (hmm..i should make a post in the near future about why i chose those 3 as the architecture over some of the other options i was considering). Yeah, java is more "wordy" than Ruby or Python in most cases, but using eclipse or netbeans can help even that out to some extent.

For those not familiar with WebWork, it does have some "rails-like" conventions built in. If you name your properties file the same as your Action class (for instance TestAction.java and TestAction.properties), you can access values in your properties file directly in your action class or jsp, with NO configuration. Sweet. Validations can be defined in external xml files, that have a similiar convention..in this case it would be TestAction-validation.xml. Again, no other configuration needed. Validation will be invoked by webwork with no real configuration or java calls from your Action. Just follow the naming conventions (which are easy to remember because they make sense), and your actions, properties, and validations will all play together nicely.

I also used Spring to wire my WebWork actions and iBatis DAO implementations. I like iBatis over Hibernate, as we like to define the SQL ourselves. I do plan on looking into JPA, however, when it becomes more stable.

Even the development/testing process is quick. Thanks to Matt Raible's Appfuse (which was used to get this app started), we have a sweet build.xml file that allows us (on our dev machines) to reload our app by having the build script talk to tomcat. So, even when a properties file or java class or static field changes, its just a matter of running the reload task in the build.xml file and tomcat reloads the app with all changes in under 5 seconds. Yeah, rails is probably quicker, but i can spare 5 seconds of my time to let my changes get reloaded by tomcat. And, of course, both Eclipse and Netbeans can be set up to run tomcat within the IDE.

Again, i know dynamic languages allow you to develop database backed websites rather quickly. However, I think the frameworks we chose, along with using Eclipse and a smart build file, can make java web development a LOT faster than it used to be. I am definitely pleased with the speed at which i can get things done, and these 3 frameworks allow me to concentrate on coding the business rules, not plumbing. I've looked into other java web solutions, and i can't imagine finding a combination that is quicker to develop in (though I do think Stripes might speed development even more than webwork, but thats also another post i intend to write about soon).

Webwork, Spring, and iBatis definitely brought some fun back to java development for me. Although there continue to be a lot of java web framework choices out there, I think today is a much better (and easier) time to be a java web developer. A lot of progress has been made in the java framework world (thanks to Spring, jdk 1.5, and some ideas from Rails). I think things will continue to move in the right direction, and we java developers will eventually get the same (at least in the same neighborhood) productivity as some of the dynamic languages.

Wednesday, September 27, 2006

My first post

I spend so much time reading other folks blogs, i thought it was time to create my own. most of my blogs will be about java and related technologies.