I am working with Asp.net mvc web application but my friend saying work with clean code most of time saying boy scout rules apply for clean code
anyone explain . shortest and suiter way
thank you
I am working with Asp.net mvc web application but my friend saying work with clean code most of time saying boy scout rules apply for clean code
anyone explain . shortest and suiter way
thank you
The Boy Scout Rule
It's not enough to write the code well. The code has to be kept clean over time. We've all seen code rot and degrade as time passes, so we must take an active role in preventing this degradation.
The Boy Scouts of America have a simple rule that we can apply to our profession:
Leave the campground cleaner than you found it - chapter 5
If we all returned our code a little cleaner than when we checked it out, the code simply could not rot. The cleanup doesn't have to be something big - change one variable name for the better, break up one function that's a little too large, eliminate one small bit of duplication, clean up one composite if statement, etc.
Can you imagine working on a project where the code simply got better as time passed? Do you believe that any other option is professional? Indeed, isn't continuous improvement an intrinsic part of professionalism?
You can also check this out: What was the strangest coding standard rule that you were forced to follow?
The boy scout rule says that you should leave the code at least as "clean" as you found it (or for the ambitious: even a bit cleaner than you found it). That means when you change a method due to a change request, you should improve the maintainability/quality of that method along the way. That could, for example, mean to improve the method's name or the names of the variables inside. The advantage is that you need to understand the method in any way (because of the change request) and that it will be tested as you will mostly likely test the change anyway. The overhead for quality improvement is therefore almost 0. Applying the boy scout rule is a very good measure to steadily improve the code quality with low risk. It also allows you to concentrate on the code that you are actually changing while not spending hours improving code you never touch anyway.