The joy of separation
I’ve spent the past couple of weeks rebuilding an ageing Flash application, a multiple choice test engine for www.passyourtheory.co.uk that derived from an existing piece of work I’d done in 2004. This application worked well enough but, because of the organic way it grew up it’s become too inefficient for a modern website. This issue gets brought to a head when the Driving Standards Agency, from whom we license the official Theory Test question bank, changes the questions each September.
We get the option of purchasing a disk containing the new questions, but because they’re still geared for book printing the only format we’re offered is a Filemaker database exported from Quark. This contains each question as a single record, whereas our application employs a nicely designed relational database, and there’s no way to export directly from Filemaker so it can be imported into our structure. We therefore need to manually add, remove and edit the questions that have changed since last time – and to make matters worse a former employee designed our motorcycles database separate from the cars database, even though they share 75% of questions. I find it terribly frustrating to have to do anything twice and ploughing through 1,300 questions twice when once could have done makes me extremely unhappy, so I decided to upgrade both database and test engine before the September 2008 question change.
First I combined the car and motorcycle databases, adding a single field that indicates whether this question or answer relates to cars, motorcycles or both. The PHP code had to be re-written to accommodate this change, but this took only a few hours. I knew that the Flash work would be far more substantial though. The application uses the timeline to load data and check that loading has completed before moving on, which makes it difficult to add new features or re-use the code elsewhere, and for that reason alone I intended to start from scratch. Choosing ActionScript 3 as the coding language settled the matter because, take it from me, attempting to upgrade a sophisticated application written in ActionScript 2 to 3 is pointless – they’re just too different and you’re better off starting again. I was determined that the new version would be lighter on bandwidth, easier to extend, entirely independent of the timeline and, most crucially, reusable: and I wanted the engine to be configurable without resorting to editing the Flash. ActionScript 3 has all the required capabilities, but in my experience is far less productive and enjoyable to use than my favourite coding language PHP.
Nothing in AS3 is simple: there are none of the “free lunches” other programming languages offer. Adding a simple Loader component to provide visual indication of download progress involves dozens of lines of code, poring over the reference manual and hours of frustrating trial and error. The more I try to use Flash CS3 the way it’s clearly intended to be used, the more frustrated I get. It makes everything I want to do harder.