One page, one Servlet
For the most part, I’ve always been anti-framework. And by framework, I don’t mean EJBs or Servlet engines, I mean fancy “tools” that claim to make things easier. I’m against using such tools for a variety of reasons but for the most part I’m against them due to complexity.
My favourite example is a tool where by you simply describe your DB tables and Java objects and it “magically” takes care of the rest. The problem I’ve always found is that it works perfect for the example application or any other similar application which uses a few “main” tables and some look up tables. But if you start getting more “complicated”, suddenly the framework can’t handle things very well and you end up writing handlers for special cases.
Form validation is another great example of frameworks that handle simple things but no so when it gets messy. No programmer likes to write form validation code. If the user misses a field or puts something incorrectly into a field, the entire form needs to be redisplayed with the user’s input back into all the fields. A few years back there was a framework that could be used to do most of this for you, and I admit, for the simple stuff it was pretty cool. It reduced the amount of simple form validation by 80-95%. But it only worked with forms where some fields were required and others weren’t. So far so good. Except that I needed to have dependencies, where if you filled in field X, you needed to fill in field Y or if you selected radio button A, you couldn’t enter anything in field B.
So now I had an app where the framework was used to validate all form input but in some cases there was also extra validation somewhere else.
So in the end, I tend to advocate the “one [web] page, one servlet” philosophy. It makes it easier to pick up the code and follow what’s going on, it makes it easier to debug and it means less mucking around with things beyond your control. And besides, saving time in the coding stage is really not all that great since the majority of your time is going to be spent debugging and testing and making changes (because the customer changed their mind.
Tue, 01 Mar 2005 10:47 Posted in Programming