Refactoring consists of four basic phases aimed at streamlining existing
code bases to make them more maintainable and easier to evolve.
Refactoring is a cycle of steps that are repeated often to keep code
flexible and understandable.
Refactoring starts with research, probing and understanding of an
existing source base. This is particularly true when working with
team-developed code, but it also applies when a developer comes back to a
module that they haven't worked on in several months. The goal is to
expose the functional hierarchy of methods and program elements.
The next phase involves isolating variables, methods, and classes which
need to be moved, reorganized, or transformed. The code fragments are
moved and merged into their new locations. Variables, file names, and
other references must be globally converted or changed to maintain code
integrity. The code of both the unchanged and modified files must be
massaged and made ready to compile.
Almost immediately, a unit-testing phase must be done to make sure that
the code migration has not hurt functionality. Quick refactoring-testing
cycles facilitate incremental improvement and risk reduction.
Kho hàng:
Có hàng