On 4th September 2005, in God’s great sovereign plan, I started work as a software engineer in the Digital IT department of the Trinity Mirror newspaper group, working on their online titles. It was a surprising move, in some ways: my passion has always been for computer graphics and games development, and it’s fair to say that web development had only ever been a sideline for me up until that point. My priority at the time, however, was to get a reasonable job that would enable me to still have a life outside of work so that I could get involved in a church where I’d be built up and equipped to serve Jesus in the long term, and Trinity Mirror seemed like it would offer that. In the event, it exceeded my expectations in every way, and any doubts I may have had quickly vanished. As a green young developer with little experience of the realities of programming in a real-world team it was a privilege to work with the very talented group of developers they had working for them, and I shall be forever grateful for the masses I learnt there about how to make great software, working on sites like Adzooks.co.uk and the rebranded Liverpool Echo and similar regional newspaper sites. They taught me the joys of agile methodologies like Extreme Programming and Scrum; they taught me the importance of actually talking to your customers and not just assuming that you know that they want or even that they know what they want; they taught me how (and how not) to write maintainable code (or at least why it matters!); they certainly taught me the utterly incomprehensible choice of a language that is Coldfusion; but above all they instilled in me a deep routed desire to avoid the cheap and easy hacks and implement the right solution in the right way.
So what changed?
For various reasons I’ve been getting increasingly itchy feet for some months now, wanting to move on from Trinity Mirror. Whilst it’s not appropriate to go into the details here of exactly why, I’d like to share with you the following lessons that I’ve learnt about myself through the perspective of my growing discontent:
Finally, do I have any parting words for my co-workers?
Farewell, Trinity Mirror!
I've been dying for some time now to write a post explaining some of the changes I've been making to Blender's DirectX exporter. In some senses it's nothing particularly exciting, but it's been a great learning experience for me, and it's unearthed some little nuggets of goodness that I just can't help but share.
I've been developing an engine to make 3D Point & Click adventure games for a few years now, and I have to admit that for much of that time I've been in a state of denial about how hard it would be to get content out of my 3D modelling package, Blender, and into my game. I'd only ever used pre-existing .X files for all my testing (good old Tiny.x!) and since Blender ships with a Python script for exporting DirectX files I wrongly assumed it be trivial to start creating my own when the need arose.
However, when I eventually tried it, it seemed to fail every time. The author was great at replying to my emails, and he was always able to diagnose some obvious flaw in the way my mesh was configured that was causing the exporter to stumble - "you've got a negative scaling factor", "your armature isn't parented to the mesh properly", "you're using envelopes instead of vertex groups for skinning", and so it went on. These things were obvious to the author, since he knew exactly how the exporter worked and what assumptions it made, but to someone like me who'd never delved into the source code, all I knew was that my mesh wasn't working properly and that I wasn't being given any feedback to help diagnose the problem.
There's a lesson in there: never let your software fail silently. If your user has ticked the "export animations" button, there's a good chance that they think their mesh contains some animations. So why not check that you agree? If their mesh doesn't contain any vertex groups that match bone names, and your code is built on the assumption that there are, it probably wouldn't hurt to tell them.
Eventually I realised that I couldn't rely on the author debugging my meshes for me forever, and that I was going to have to get my hands dirty to figure out why my mesh wasn't working. I very quickly discovered what people have been telling me for years: it's far, far harder to read code than it is to write it. I wasn't helped by the fact that I'd never written a line of Python before in my life, nor did I have any knowledge of the Blender API. To be honest, I really rather enjoyed the challenge of figuring out this mysterious piece of code. Here are some of the tricks I used in my siege upon the citadel of mystery:
Having started to understand the code a bit better, I gained the confidence to start making some improvements of my own. Here are some of my favourites:
name.replace(".", "").replace(" ", "_"), to deal with the fact that object names inside a .X file can't have dots or spaces in them. Now, in some ways this seems harmless enough, but I wanted to factor it out into a method call anyway, just because I've got a strong dislike for 'copy and paste' coding. I could have named the method, "remove_dots_and_spaces" (a 'how it does it' name), but I've come to realise that a semantically descriptive name is much more useful, so I called it "make_x_compatible_name" (a 'why it does it' name). By doing that, it got the creative juices flowing, and I started thinking about what else might cause a name to break your .X file, and came across an example where using a reserved word (e.g. 'string' or 'integer') as a name caused it to break. Having a method factored out made it trivial to add some code to check for reserved words, and the change then immediately applied everywhere that method was used. Fantastic!