The Summary: Refactoring is a huge aid in
untangling production code without breaking it, and in improving its
long-term maintainability.
Refactoring helps you achieve:
1. self-documenting code, for better readability and
maintainability, which is pretty much the only kind of code documentation
that ever seems to stay current (Extract Method and Introduce Local
allow you to create function and variable names that are descriptive enough to
rarely need comments). Until you experience readable, self-describing code, you
don't know what you're missing
2. fine-grained encapsulation, for easier debugging
and code reuse: Extract Method automatically determines the
parameters needs in order to create a method from the current selection, and
handles them correctly. You then know exactly what external information the
selected block requires in order to operate. This can be a great aid in
untangling complex code during code reviews or debugging.
3. the generalization of existing code, to make it
easier to apply existing code to a broader range of problems - as you Extract Method, you can easily replace things like hard-coded constants
(perhaps, a connection string, or a table name) with parameters, thus allowing
the application of proven code to new contexts.