Objects: simplicity itself
Posted at 21:38:00
on Fri, May 05th 2006 by graham
in:
programming
Another techy post, I'm afraid. I'll get back to the writing / ranting / mumbling ones in a bit. Promise.
A nicely productive and generally un-frustrating day as far as Das Projekt is concerned, though if Eclipse crashes one more time when I try to update it I might just start getting a mite ornery.
Managed to get a couple of niggling bugs nailed down this morning, including an annoying database issue that turned out to be caused by two libraries using two different database APIs but the same basic SQL statements, with the upshot being that one knew what to do with the SQL whilst the other just shrugged its shoulders and washed its hands of the matter. The trouble was that the second library was only being called on a sporadic basis, making the bug that much harder to track down.
Now that I've got the big things done, at least in outline (for example, one of the Big Things is a scheduler that sends out SMSes on, er, schedule. It doesn't actually do that yet, it just pretends to, but it's just a case of uncommenting a line of code and we're away) I can just go through the list of required features, code them and then tick them off. Hopefully that won't take too long.
One of the happy consequences of my doing this work is that I've produced a lot of very re-usable code. Part of the spec for Das Projekt was that its original creators had meant for it to become an all-purpose platform that could be sold to all and sundry. Unfortunately, due to time restrictions that hasn't happened, but I've tried to write my code in a way that will make it very flexible when they do come to produce something that they can sell.
It's one of those situations where my own code has surprised me. Things have just worked, which, though not a novel experience for me (he boasts), is still a pretty gratifying one. What I mean by that is that I've written a number of small frameworks that allow new additions to the system to be added in a few lines of PHP. You want to handle a new incoming text message? Write a quick handler and drop it into the MOHandlers directory. All handlers descend from a common hierarchy and have database access where needed. Need different database access? Don't want to write the SQL to do it? No problem: we have table gateways and OR mappings to take care of it all for you.
So a lot of what I've been doing today has consisted of writing a couple of lines of code, dropping it into place and then sitting back and saying "Oh. It worked. Shiny." a lot. Which is why this post by Andy Skelton about his experiences writing the WordPress widgets hierarchy (which sadly never got used) struck a chord with me when I read it.
Objects are cool, and that's all there is to it.

