The boy scout software developer

Recently, I was reading about “The Boy Scout” and found interesting article about one of the Rule:

Always leave the camping ground cleaner than you found it.

How the boy scout rule applied in software development principles ?

Always leave the code cleaner than you found it.

Why isn’t easy to follow ? It means I have to get good understanding of code, before I make a change. Let’s take a example: I have given a task to build feature X. I saw something that smelled. It had lot of duplication of code. My task was to add similar behavior. Since the code was already written, I went ahead with easy route. I followed same pattern and end up adding more duplicated code. Mistake, I didn’t follow the boy scout rule. There might be good reasons for it like business critical deadline, lazy follow existence pattern or any other.

Lesson learned, If I would have followed the boy scout rule,

  1. Refactor the code
  2. Generalized it
  3. Make it re-usable

Continuous improvement is an integral part of our job as software developers. Even as small change to rename variable to more meaningful name, get rid of duplication helps always help in improvement and maintainability of code.

Code becomes better and better in every small steps you take.

Great Resource: Clean Code by Martin Robert C.

The only way to always go fast is to keep the code as clean as possible.