The goal of refactoring is not simply to reduce the lines of code, it is to make the code easier to work with in the future. This may sometimes mean writing more lines of code. You might take 5 lines of code and generate 15 lines by creating additional functions or objects…
Whenever you start counting the number of lines of code added or removed, then you are measuring the wrong thing (1). I’ve seen some people reject great refactorings because they added more lines of code. Just remember that refactoring isn’t about reducing the size of your code, it’s about increasing the quality of the code. Size doesn’t matter.
(1) Unless you’re removing a ton of code by using a standard library instead of custom code. e.g. removing 1,000 lines of custom authentication in favor of a authentication gem.

No comments yet.