It’s a hack… but it works.

Last week I needed to finish the attic — I was putting down more insulation and creating a raised platform so we could store our many, many, possessions in the attic. I say this with a sense of ennui, as I feel like adding more space to store things encourages storing more things (kinda like expanding highways causes more traffic). But anyway, since my house was built in the 50s, there are quite a few gotchas in putting this platform down. Things like dealing with rafters that have faux headers (used to ensure the structure didn’t ‘shift’ during construction before the roof was put on), or random wooden beams that hang off into space.

So, at one point, it was either put a corner into a void or spend another hour working on the attic.

So I chose the hack.

The hack was that since this part of the attic would (at most) hold one box, and never a human, I could get away with letting the stud hang off the end of the ceiling beam.

This was a hack, and I can only imagine what someone who sees this in 40 years says.

I can’t really leave a note for them; so I guess they’ll think the previous owner was an unqualified hack.

They’d probably be right; but they’re also forgetting the context I was operating in — finishing the attic during a global pandemic so I could have my office back.

The good news is that with TDD and unit tests, you can explain your hacks to people who come after you. Comments work, though they often lie because they can’t be guaranteed to stay in sync with the code. That’s their chief problem. They lie.

The cool thing about your unit tests (and TDD is even better at this) is that they have to stay in sync with what the code does, otherwise they’d break. They can’t lie (though if poorly named or shaped, they can mislead).

The next time you need to make a hack in code; think about producing a characterization test that explains why the code does what it does; and indicates in what circumstances the code (and its tests) would be safe to remove. This may be a more brittle test; but given that it’s documenting a hack, that’s probably a good thing.

(If you’ve read the last post titled “Chesterton’s fence”, you’ll probably notice that this post is a corollary to that one. I’d like to think it’s worth your time if you haven’t already read it).

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.