re: Old Article: Someone Is Changing Your Code VIEW POST


Nah, it's not you. This is sort of an amorphous concept I'm trying to get into words, but it's hard to express right.

I actually might nuke this article, rework it, and publish it later.

But the general thesis is this:

Someone somewhere is going to change the code that you write.

You may think you have control over how they change it. Some folks have suggested in the comments with fixes like code reviews, tests, or just "who would ever do that". But the real truth is that you will likely move on from the code you wrote, move to a different team or company, and someone will change your code.

You won't be around for code reviews. They'll delete your tests. And they won't have the context to know why you shouldn't do XYZ. (Though admittedly the isAdmin example in this article is a little on the nose).

Given enough time, someone will change the thing you write and they won't have the context you do.

So if you take that as a given, then it follows that each piece of your code won't be interacting with what you wrote, it'll be interacting with what other people wrote.

For example, if you wrote something like this:

function mixFlour() {}

function addEgg() {}

function bakeCake() {

Then your bakeCake function should act as if it was unaware of addEgg and mixFlour, even though you wrote that.

Because eventually, you won't be the author, someone else will be.

This mindset reduces the number of "implied" dependencies in your code (where one piece depends on another in name but not in structure).

Hopefully that makes more sense, but if it doesn't sorry, it was written pretty quickly.

code of conduct - report abuse