My favorite confirmation message is just two words.

I use versioning, Git, for the most part, all the time, even with little scripts that no one will see besides me, even when I probably don’t need it. Just I like it. Something about using version control or managing the source code or whatever you want to call it makes my coding process more fluid.

And I noticed something interesting, committing code to some repository or another almost every day for the last few years. I have a confirmation message that I use over and over again.

It’s this: “code compression”

All lowercase, just like that.

That’s a kind of shorthand … I’ll explain. Imagine I have code that already works. You have unit tests, probably (though maybe not enough of them … another topic). But you have unit tests that are passing, or maybe not, because the script is simple and I’m just testing manually.

So I added the changes to the repository and already committed. You are engaged in a (partially) working state.

So, I do better.

What should I do? I change the name of the variables, functions and methods, so it is more readable (understandable) when I or a teammate are modifying this 11 months later and I don’t remember what we had in mind back then. I take five or 20 or 100 lines of code and simplify it. So that it becomes two or seven or 35 lines. Everything I can cut.

No news. Zero progress in functionality. I just make the code more readable, easier to maintain, or better. You went from one work state to another equivalent work state. A completely horizontal movement.

And then git-add and git-commit. With the message “compress code”.

This often makes the code base smaller, in terms of lines of code. In a way that (more importantly) is more readable and easy to maintain. But it still works just as well.

More elegant, in other words.

But not always. The actual changeset doesn’t * have * to reduce lines of code. If I change the names of the identifiers, that basically has no effect on the size of the code. Heck, I can take a dozen dark lines and in the process of de-blurring it, it’s now something like 80 or 200. So I’m not always compressing the code.

But regardless, it is an improvement.

This is great to do in your own private branch, where you can do a trillion little confirmations and no one will give you a hard time about it. Sometimes I’ll have three “code compression” commits in a row.

I do this so often, so often, that I just settled on the phrase “code compression” so I don’t have to think about what message to write. There is probably a better name for it. But I can’t be bothered to change that habit. That requires willpower and I have other habits that are more important to change.

But maybe you get the idea.

The good thing about this concept:

Just knowing that you can use “code compression” as a confirmation message,

automatically makes you think about how you can continually IMPROVE

your code.

Give it a try today. Because you will love The results.

Leave a Reply

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