Let’s start simple. Here is a situation I have encountered more than once. We have this big long class or method, and embedded in it are several blocks of code, all commented out.
def some_method(a)What should I do? Given the code is version controlled, I would happily throw it away.
do_something(a)
calc_another
# wow
# do_do
# calc_calc
# zcalc(z)
end
The code is commented out and will have no effect whatsoever on any program or user. Another programmer may be affected by it, though. So, make a note in the commit message :
“removed commented-out code in such-and-such method. haven’t been used in a while”Caveats apply for very large blocks of commented-out code, or it has warnings not to remove. But these can be easily solved with some programmer-to-programmer communication.
There are other things that can be theoretically thrown away, such as:
- Once off experiments / prototype
- Quick and dirty functions
- Generally ugly code in the project
* I have always wanted to write down some of my experiences as I embark on a programming life. This is my starting contribution.