Working with Legacy code #7 : The boy scout rule.

Uncle Bob outlines this concept well in in the 97 rules book.

 Leave the code a little cleaner than you found it

In other words where you can improve and make better the code you are working in. In legacy code you should follow this concept with a blazing degree of intent. By its very nature legacy code needs to be better and no matter what you are doing or where you will need to improve it.

YANGI?

In legacy code it is always a temptation to leave behind the small things. Let's take for example a small function that has two 'return' exit points. While you can agree that such a small function may not cause too many problems and changing the function violates YANGI you can fall into a trap. Some else comes to that function and follows it's structure to add yet more exit points. Soon the function carries more technical debt weight then you came across it.  With the boy scott rule you leave nothing behind, if you see it might cause problems not only for you, now, but also for the team in the future you make it better.

 

No Comments