Sunday, October 25, 2009

Super Frameworks - develop Java web apps at lightning speeds

In the early days of J2EE (that's how we used to call Java Enterprise Development back then) we had fewer alternatives of technologies, frameworks and reusable components. Web application development was then far simpler than it is today - there was no need for developers to learn a bunch of different things like Spring, Hibernate, JSTL, JSF etc - and things were much simpler to learn and understand. I am not that nostalgic, however, because some big drawbacks compared to what we can do today are that most of what we did was not really reusable (it is hard to consider Copy/Paste as reusable code), we had to spend time writing low-level logic to handle aspects like persistency and logging, code was hard to unit test... the bottomline is that we had to spend more time on infrastructural aspects of our systems than on business logic, essentially killing our productivity and making code quality suffer.

When someone pays you to write a system they want it finished on time and working without bugs. And 99% of the time they have no idea what a JDBC or some other arcane technical acronym is, so they expect you to focus on the screens and public APIs, not in infrastructural code that has nothing to do with visible functionality that they are interested in.

Then few years back we started to see many production-ready frameworks and technologies pop up as new alternatives in our Java development toolkit - far too many actually, but I still think in this case it is better to have more than less. Frameworks and tools like Spring, Hibernate, Struts, jUnit, Ant etc focused on multiple different aspects common to most Java projects like persistency, security, presentation, logging, building and testing, thus improving our productivity.

But then, while this new set of tools helped reduce the need for us to re-invent the wheel it also made the learning curve considerably more steep. Now, just to create a new project we have to install a bunch of frameworks and then integrate each one. It doesn't sound that bad, but let me tell you, it is bad. Instead of wasting time writing connection pools developers now can spend (many) days figuring out why Spring isn't working properly with Hibernate or some other framework. Again, they are not focusing on the business functionality their clients are paying them to deliver.

There are multiple alternative solutions to this problem, each with its own set of advantages and drawbacks. One is to forget Java and move on to another platform like Ruby / Ruby-On-Rails. Instead of a Frankenstein-like system requiring hundreds of independent frameworks patched together, RoR is just one single framework that tries to address most of the aspects I mentioned before. Because of this RoR is more consistent than a bunch of frameworks implemented by different teams. But while many developers love RoR with passion (or perhaps they needed a new theme to sell books?) it is still just a very small niche if we compare it with Java.

A more enterprise-friendly alternative (and therefore one that may help you land in more jobs) is the use of a super framework - which, as the name implies, is a set of frameworks packaged in a pre-configured, pre-integrated manner, with tools to automate redundant manual tasks to improve productivity and quality. There are also dozens of such super-frameworks based on Java but probably the two most known ones are JBoss Seam and AppFuse.

Seam comes packed with more functionality than AppFuse, but it is also less flexible. I don't advocate one over another, but I do believe that if you work implementing web-based Java applications you should consider using something like that. Seriously, after you learn well how to use one of these frameworks you will be amazed how much faster you can do things you did before, like web UI tests, web services, security etc. Not to mention your boss will think you are the fastest developer on Earth, if you do a good marketing of your work.

There are few books available describing both frameworks in detail but you can learn a lot from the project official pages and user forums. There are tutorials you can follow, and the forums have very responsive developers (at least that was my experience) to help answer questions and troubleshoot issues.

I spent a good time learning and working with AppFuse since its version 1.9.x and I can say it was one of the best things I did for my career since I took my first Java certification, back when these certifications were worth something.

No comments:

Post a Comment