Code refactoring

Code refactoring is the process of changing the structure of an existing code without changing its external behavior. The purpose of refactoring is to improve an existing code. This improvement can be made for many different reasons. We might want to make the code more readable, less complex, easier to maintain, cheaper to extend, and so on. No matter what the reason for refactoring is, the ultimate goal is always to make it better in one way or another. The effect of this goal is a reduction in technical debt; a reduction in pending work that needs to be done due to suboptimal design, architecture, or coding.

Typically, we approach refactoring by applying a set of small changes without modifying intended behavior. Reducing the scope of refactoring changes allows us continuously to confirm that those changes did not break any existing functionality. The only way to effectively obtain this confirmation is through the use of automated tests.

One of the great benefits of unit tests is that they are the best refactoring enablers. Refactoring is too risky when there are no automated tests to confirm that the application still behaves as expected. While any type of test can be used to provide the code coverage required for refactoring, in most cases only unit tests can provide the required level of details.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.184.102