
When I got into the other stored procedure, I was lost. The procedure was 850+ lines of code. There were nested IFs that were six, seven, and even eight levels deep. I was around when this procedure was changed over the years. And I still was getting confused over the thing. I decided to print out the code, and line up the IF and ELSEs.
My goal was to refactor this massive procedure. The plan was to break down this monster proc into many subroutines. In the end, the main procedure got down to 150 lines of code. It was much easier to follow. Of course all the lines of code went to small subroutines. I needed to do a bit of regression testing to make sure I did not break anything. With a change of this magnitude, there are going to be some bugs introduced. My unit tests helped flush them out. I am leaving this procedure is much better shape. I am proud.