Code sustainably

Dean Matter
2 min readFeb 8, 2022

It’s a typical Friday afternoon at the office. Or, if your office days fall earlier in the week, you’re finishing the last few items of work for the day from home. And, being candid with yourself, your productivity isn’t quite the same as a Tuesday morning’s. And that’s alright; being ‘most productive’ sometimes means you’re less productive at other times. You’re hoping to just get this final unit test passing before knocking off for the weekend, when “PR #204: Bugfix/small-urgent-refactor” lands in your inbox.

If you’re like me, you get a little over-protective of your team’s codebase. You’ve spent plenty of time contributing your own features and reviewing team members’ contributions. Reviewing colleagues’ code sometimes feels like I’m a parent trying to dictate exactly what a teacher should teach my child. Nobody wants their child to come home and echo the artifacts of a faulty worldview held by their (probably-trying-their-best) teacher. And no team wants a subtle bug to be introduced into their codebase on a Friday afternoon because the contributor was trying to ‘fix’ a surface-level bug instead of diagnosing the underlying issue.

Don’t lay watery pipes on Friday afternoons

I’ve seen plenty of these PRs flying in, usually written by panicked colleagues who don’t actually need the work to be done that urgently, but have gotten caught up in the stress of trying to make it work, ‘for management’. No good dev work is accomplished in a panic, nor in the 11th hour of a workday. I understand that there are extraneous circumstances and urgent prod fixes needed from time to time, and they’re inevitable. But when the majority of your output resembles these shoot-from-the-hip, hacky solutions, you need to rest and start approaching your work in a more sustainable way. As soon as a colleague tells you, “it’s a little bit of a hack to get it working,” then any subsequent rationalization for their poor code should be discarded. Reliable and well tested code is not built with little hacks sticking it together. It’s written slowly and methodically when you’re well rested, exercised and focused.

--

--