Boy Scout refactoring works but can take 189 years (still faster than waiting for motivation)
Tom Nijhof
Posted on March 25, 2024
The Boy Scout principle, “Leave a place better than you found it,” is an admirable philosophy that can be applied to many aspects of life, including coding. Refactoring a large code base with this principle in mind can be a challenging task, but it’s certainly possible. Can you replace one language with another? Well, I wondered about this and I found a use case where this happened — the Dutch Law.
What is Boy Scout refactoring?
The Boy Scout principle is to leave a place better than you found it. This can be cleaning up, adding something, or updating something. In code, we use this as an excuse to refactor every piece of code we have to work on.
A great upside is that you never plan time to refactor. You also never spend time on just refactoring. And in general, it costs less time, because if you already worked on the code the refactoring will go faster.
However, not all code gets updates at a similar rate. Some code will be updated every sprint, other code will never be updated after it is written. So what if a standard changes before you update the last code? Well, now you have 3 standards, good luck!
The Dutch Law
Let’s go over a bit of history, in 1813 the Netherlands broke free from France (again). This is the point where the current Dutch law can be traced back to. This is not the beginning of the Netherlands, but the beginning of the current Dutch law (let’s ignore the rest of the messy history).
The Dutch made an important decision, “we keep all the France laws we have from when we were puppet state and rewrite them in Dutch when we update them”. So basically Boy Scout Refactoring.
And so they did, every time a law needed an update it would be rewritten in Dutch. It took till the 31st of October 2002 when the last law was rewritten! 189 years! (link)
For those wondering, the last law is *Loi concernant les Mines, les Minières et les Carrières; *Something about mining.
What happened in these years? Well:
Belgium broke away from the Netherlands.
Luxembourg and the Netherlands stopped sharing a head of state because a Dutch succession law allowed for a woman and Luxembourg did not.
World War One happened. This left Keizer Willem in the Netherlands until the German monarchy will be restored (his grave is still here) (link).
World War two, when the Nazis introduced more laws into the Netherlands. (link)
Indonesia became independent followed by Suriname
The European Union was founded (now we have laws in France, Dutch and 22 other languages). (source)
I was born (maybe a slightly smaller event compared to the rest)
Conclusion
When it comes to refactoring, the Boy Scout approach is not a substitute for more comprehensive techniques. While the Boy Scout principle can be a useful tool in certain situations, it’s important to recognize that it’s not a one-size-fits-all solution. In order to effectively refactor code, it’s important to use a variety of techniques and approaches, rather than relying solely on the Boy Scout method. By incorporating different strategies into your refactoring toolkit, you can ensure that your code is always well-structured, maintainable, and efficient.
Posted on March 25, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.