Blog Posts in "programming"

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.

Feeding the hungry codemonkey

Posted at 22:54:00 on Thu, May 04th 2006 by graham
in: programming

In an addendum to the last two posts, I've discovered something else about myself: Although when writing I'll procrastinate by doing anything that isn't writing, when I'm coding I'll procrastinate by... coding.

Case in point: Tonight, working on the ORM for the Project, I realised that I'd spent an hour an a half moving methods back and forth between a class and its ancestors, trying to find the most code-efficient configuration for a particular set of features that, whilst being similar for each descendant of the superclass, are not exactly the same and require tweaking a little bit with each new descendant. I think I've found it now, but I could have just reverted to the copy and paste school of code reuse and saved myself a lot of time.

Mental note made, then: don't procrastinate by working on something so irritatingly infinitesimal. Yeah, right, that'll happen.

Now that I've got a handle (or at least now that I think I've got a handle) on the ORM thing I can get on with what I was supposed to be doing, most importantly with building a scheduler for sending out SMS messages. The scheduling bit is simple, especially if I write a simple table data gateway for the scheduler's database tables... See there I go again, coming up with a concept that will make my life easier, but only once I've invested a great deal of time and pain in building it. Silly.

Here's a better idea: I'm wiped. I'm going to bed. Project be damned for the next eight hours.

And that means the Great Orm will come in the night and wind out my entrails on a stick!

Posted at 16:25:00 on Thu, May 04th 2006 by graham
in: programming

... "And suck out my eyes, my mother said!" ~ Arthur, Pyramids.
I've spent most of the day wrestling with the Great Orm - or rather ORM. Not the Discworld god, of course, so my entrails are safe, but with the concept of an Object-Relational Mapping and how complex it is to implement such a beast for the Project. Let me just point this out: I work a lot with databases - kinda comes with the territory - but I slept through or just otherwise missed my lectures at University on the subject of ORM and object-oriented databases. Partly this was because I was tired / hung over / busy with other things at the time, but mostly it was because the lecturer, known for various reasons to the undergrads as Apu, was boring and besides I couldn't understand more than every ninth word or so that he said. But in some ways its been quite fun. Again, it's the mental clicking thing: see a problem, ponder its solution, click, write the code. And I've been doing it to the accompaniment of The Wonder Stuff's latest album, which is well worth a listen. But I have to say I'll be glad when the project's done with. Writing a good bit of story is much more fun than writing a good bit of PHP.

Re-learning the basics

Posted at 22:49:00 on Wed, May 03rd 2006 by graham
in: home programming writing writing ideas

It's funny, but even though I've been programming professionally on a day-by-day basis for the past two and a bit years, I've only just rediscovered one of the things that I always found difficult about programming when I was doing it as a student (and therefore from home), which was this: I procrastinate. A lot.

Now, wait, I know what you're thinking. You're thinking "But Graham, we know this. We read your blog for cryin' out loud. You procrastinate when you're writing. You go on about it all the time. Why are you surprised?" And you're right to think it.

But until I'd started programming from home again (I'd avoided doing it whilst I was programming in the workplace all the time - the last thing I wanted was to face even more code when I came home) I forgot it. I think this had to do in part with the fact that I used programming as a form of procrastination from writing. Instead of working on my word count I would sit and tinker with a bit of code for a while, maybe something that I'd created a while back and wanted to tweak to my current needs or maybe (and these were always the most distracting) trying to work through a thought experiment in code.

Whatever the reasons for doing it I was using coding as a procrastination tool. Now I'm coding at home and I'm finding that my day consists of roughly the following cycle repeated with alarming regularity:

  1. Sit at computer.
  2. Fire up Eclipse.
  3. Check email. Read Bloglines, LiveJournal, etc.
  4. Go back to Eclipse.
  5. Code for a bit.
  6. Sigh. Decide tea is needed.
  7. Go and make tea.
  8. Get distracted by something (usually reading).
  9. Make more tea, first mug having gone cold by this point
  10. Sit at computer
  11. ... lather, rinse, repeat.
Luckily I've managed to get a handle on the problem fairly quickly. For me programming, like writing, is a case of seeing a problem and waiting for the mental click of everything sliding into place so that you can solve it. Now, the project seems to have reached that critical mass where I can just write code for hours on end without having to eat, drink or do much else.

The trouble is, of course, that I'm now itching to write, or at least to edit the novel some more. That will come in time of course, hopefully once the project's done and dusted with. But the fact that I've got the itch is a good thing, I think, because it means that I haven't just lost the urge to write. In the long run, I'm still a writer. At the moment I'm a programmer who happens to moonlight as a writer. In time, hopefully, I'll switch those around.

In other news, all this programming has lead to an idea for the next novel, or at least for a novella. Now all I have to do is work out how to write a story based around computer programmers without boring everyone to tears. Watch this space.

Thematics

Posted at 20:38:00 on Sat, March 26th 2005 by graham
in: computing programming

I've been playing about with WordPress Themes, trying to find one that fits my personal design aesthetic whilst at the same time maintaining the actual readability of the site. I'm not entirely sold on using WordPress as a full-blown CMS yet, and since I couldn't find anything that suited me online I'm going to build my own instead (trust me, after working on the Pendle Council website's CSS nothing will be complicated ever again).

The upshot is that this page might appear broken from time to time in the coming weeks. Sorry about that... 

Search

Latest thinkings

Interestingly, the rock mix of "I kissed a girl" (thanks, Exaile) is far better than the standard release. 2009-01-08 16:16:31

Recent entries

Launchpad Bugs

Post Categories

10mm 15th of july upload america amusing animals atheism august9upload august 9 upload autoportrait bass bbc bird blackandwhite blogging blogs boat boston buildings candid canonical caton church colour colourised computing cricket d300 d40x desaturated django editing flickr flower forestofbowland friends from the inbox funny general heysham home humour in the news lancashire lancaster landscape launchpad links linux london lune massachusetts may 12th upload me monochrome morecambe morecambebay music nanowrimo nature neil gaiman news new site night nikon55200mm norfolk norfolkbroads novel novel-the-second observations pendle people photography podcasts portrait posts that started out differently programming python quotes ranting reading reflection religion science sea selfportrait sepia september mass upload the first shadows sigma1020mm sign silhouette silliness sky stupidity sunset texture thoughts three hundred and sixty-odd days of 2008 travel tree twitter ubuntu uds urbandecay warren ellis, internet jesus water work writing writing ideas

About

Graham Binns is a writer, photographer, musician and software developer from Lancaster, England, with far too much hair, a penchant for odd t-shirts and a magnificent hat. He has been making things up for as long as he can remember and has been making code work for long enough to make a living from it.

He has written one novel, which is in the process of composting, and is working remembering how to write before embarking on a second. In the meantime, he photographs things, since it's easier not to have to make the world up in his head all of the time.

From the gallery

Rosie Alan Pope and his portable Daviey Hollow and of no use Slightly Camp Jesus Ubuntu AllStars - Jaunty Jackalope Edition