Code refactoring

In computer programming and software design, code refactoring is the process of restructuring existing source code—changing the factoring—without changing its external behavior.

Refactoring is intended to improve the design, structure, and/or implementation of the software (its non-functional attributes), while preserving its functionality.

Typically, refactoring applies a series of standardized basic micro-refactorings, each of which is (usually) a tiny change in a computer program's source code that either preserves the behavior of the software, or at least does not modify its conformance to functional requirements.

Many development environments provide automated support for performing the mechanical aspects of these basic refactorings.

If done well, code refactoring may help software developers discover and fix hidden or dormant bugs or vulnerabilities in the system by simplifying the underlying logic and eliminating unnecessary levels of complexity.

This is in sharp contrast to what typically happens: little refactoring and a great deal of attention paid to expediently add new features.

If you get into the hygienic habit of refactoring continuously, you'll find that it is easier to extend and maintain code.Refactoring is usually motivated by noticing a code smell.

Once recognized, such problems can be addressed by refactoring the source code, or transforming it into a new form that behaves the same as before but that no longer "smells".

Performance engineering can also tailor software to the hardware on which it runs, for example, to take advantage of parallel processors and vector units.

[7] The turnover of teams implies missing or inaccurate knowledge of the current state of a system and about design decisions made by departing developers.

Such deterioration affects architectural properties such as maintainability and comprehensibility which can lead to a complete re-development of software systems.

[10] Providing a comprehensible format for the inner-state of software system structure, data models, and intra-components dependencies is a critical element to form a high-level understanding and then refined views of what needs to be modified, and how.

Martin Fowler's book Refactoring: Improving the Design of Existing Code is the canonical reference.