Thoughts on frameworks

I’ve been building dynamic web sites for over ten years now, and one of the things which has bugged me enormously is the huge amount of repetitive code I have to write, especially for form handling (including validation) and access control. At least half of my coding time is spent on this sort of work, and the lack of creativity involved leads to boredom, which inevitably leads to dissatisfaction with the work and mistakes. Apparently though, there is this silver bullet called a framework, which will solve this problem for me…

I heard about frameworks a few years ago, when the various web development groups were getting all excited over the memory-eating monstrosity which is Ruby on Rails, under the reasoning of ‘37signals use it, so it must be the best thing since sliced bread!’ I went as far as reviewing a book which was aimed at PHP programmers who wanted to get to grips with Rails, but I wasn’t convinced that it was any good. The initial investment, in terms of the amount of time required to learn the framework and the Model View Controller way of doing things, was also too much of a hurdle. Sure, I might save some time in the long run, but there was no guarantee that this would warrant spending an undefined amount of time getting to grips with the framework’s particular way of doing things.

However, I’ve been playing around with Django this weekend, and I must admit that it has impressed me (this is not a simple achievement, for I am terribly fussy about anything to do with programming, whether it’s a library, framework, IDE or coding style). Like any framework, it has the ability to turn models into database structures and forms, a built-in admin interface and scaffolding which you can gradually replace with your own templates. Its major selling point though is that it is incredibly easy to pick up. I put this down to two reasons:

  1. It has good documentation, including a self-contained tutorial.
  2. It has good documentation, including a self-contained tutorial.

I realise that’s actually just one reason, but it’s so important I feel it’s worth stating twice. As a result of the documentation, someone who has never programmed in Python (apart from a one day tutorial more than a year ago) has been able to create a clone of a site written in PHP in about half the time. As a result, I’ll be using Django to rebuild Pub Gateway over the coming weeks, and then moving on to kick start Rogue Students, which I’ve neglected for some time.