Home extensions

Home extensions

You should write your code like you build home extensions. If you don’t build home extensions, then at least imagine how you might build a home extension. (if you don’t do either regularly, then you’re reading the wrong post.)

[Giving credit where it is due: one of my experienced colleagues articulated a flavour of this metaphor to me and I wanted to develop the metaphor to inform my own thinking about software.]

So why should you heed this instruction? Well, code should be written to be read, which means that just like a home extension, code should make sense. The code you write should not be an ugly appendage you sew onto some Frankensteinian module - don’t just bolt things on. New code should be a logical addition which fits with what’s already there, just like a home extension should fit seamlessly with the existing house. A tasteful home extension should be from the same materials, the same colour scheme, and follow the same geometry as the existing house. If you just tack on a demountable shed to a Victorian mansion, your neighbours will probably hate you. If you’re in the US, you might even get sued. Home extensions, like good code, should make sense.

As a developer, you should exercise your creative license. Think how easily software can be edited - the home extension metaphor, while it’s useful in thinking about coherence, does not capture software’s malleability. When refactoring code, developers can reshape what is already there so the new extension fits. Code is much more changeable than gyprock (or pick your favourite building material), which means existing code can be remolded so the final product is logically coherent. Nevertheless, the home extension metaphor is still a good guide: extensions should be minimally disruptive to what’s already there. Adding an extension to the back of the house to make the living room bigger shouldn’t make the kitchen and bathrooms unusable.

An aside: the language of software development often mirrors language used in design and construction for good reason. Houses are built from the ground up in a series of layers: the foundations are put in first, then the walls, and so on. Relating decisions made in a code base to the physical construction of a building might be a useful exercise that could future-proof that code base.