The everyday ramblings of an everyday geek.

Monday, November 21, 2005

Writing Apps

It started as a 5 minute exercise just to test my JavaFu. 2 weeks in and I'm gob smacked at how complicated this exercise has become. That exercise is ButtyMaster.

The Problem:

One of the guys I work with makes a butty order every Friday morning. It started as just a few people, but has grown to over 60. Each of these people ring him either on Thursday afternoon or Friday morning to request a butty. Most people have a 'usual' other people like to change their butty from week to week to week, the whole thing is stored in an excel spreadsheet that is printed off and faxed to Butty Shop. Not only is it taking over his Friday mornings, it's also costing him a lot of money, as the whole order comes in at over £100 which he then has to ring around to get back. He needs a system.

The analysis:

So what is the best way of dealing with this problem? Well, I'm a Java programmer, so my immediate reaction was to write a Java program, but what sort?

Do I write:

  • Distributed Swing program that talks to a central database?
  • A centralised web app with a database backend?
Lets face it, Swing is terrible. Its slow, convoluted to write, is difficult to upgrade once its out in the field and relies on people being able to run Java programs locally - definitely not a guaranteed. In fact, the only time I've seen any compelling reason to use Swing was Eclipse, but even then your left thinking - I wish this was written in something a little 'snappier'. So a web app it was, and that was when the work started:

What login system do you use?
Should I use a portal tool?
Should I use struts / JSF?
Should I use EJBs / Hibernate / DAO
Should I go for Weblogic / JBoss / Tomcat?
Which database should I use?
Should I use a database?
Where should I base it?
Should I design for easy maintainability or speed of development?
Should I use AJAX?
Should I use HTML / XML / XHTML?

In the scheme of things this is a very simple application. All people need to do is login, add/ change / request a butty and then logout. The average use case should take less than 5 minutes to complete, and yet its turning into a monster. I guess that's the problem with Java web apps. Java forces you to ask these questions as it makes no assumptions for you. The whole language is designed to make you think about the security and concurrency issues associated with an application, that even on this low level, requires the coordination of some many interacting parts.

And in that respect I'm probably using a sledgehammer to crack a walnut. PHP would stop me from being able to make any of these decisions as I'd put all the code in the page. Of course, this is at the expense of ease if change later on in the process.

Perhaps I could create an Access front end to a PostgreSQL database and make that available on the company intranet. Certainly a strong contender, but that means that everyone needs to have Access and as I learnt on the Forklift project, Access makes a lot of things very easy, but other really important things almost impossible (it's also as reliable as a chocolate teapot).

So here I am with ButtyMaster the Java web app. I've designed the database, and now I'm looking to connect it to the app. Even this involves a lot of choices, the current one being do I use a pure JDBC 2.0 solution, or use SQL and JDBC 1.0, should I be building stored procedures, do I need to use DAO, if so should I use an interface? I keep telling myself that this is just a butty app, that really I don't need to worry about any of this, that premature optimization is the root of all evil: perhaps, the reality is, the problem is more complicated that I thought.

0 Comments:

Post a Comment

<< Home