How to write cleaner code

The boy scout rule

Yesterday when I was reading a book Clean code I ran into the boy scout rule. It reminds me of when I heard it about 3 years ago the first time from my senior colleague.

Always leave the campground cleaner than you found it.

We can apply the same method for development. With every pull request. Is there something to improve? it can be a constant name or some line formatting in the file you are touching, even though it is not a part of your task. You make it a little bit better before you make the pull request.

It is something that doesn't require much effort. Over time our application would incrementally get better and cleaner with every pull request.

If we take one step back, and let's have a look from a bigger scale. This approach is about continual improvement which is the ideology of Kaizen. The word itself comes from two Japanese words. Kai means improvement and Zen means good. We can translate to continuous improvement, where everyday we make a small improvement towards our goal.

image.png