Code refactoring is the process of improving the structural design of code without changing its functionality. It is typically done to improve the stability and quality of code. Code refactoring can potentially repair undiscovered bugs and improve the speed of future development by making code structurally sound and comprehensible.
ExampleA bank system has been operational for 10 years and has been updated by hundreds of developers over that time period. The code is duplicative with several variations in structural design for similar products. Some of its classes have a large number of instance variables and methods. Methods are often long and exhibit an adhoc structure that is difficult to understand. In recent years, it has become more common for changes to have unintended side effects that have caused regression tests to fail and production issues to occur. The lead developer approaches management and proposes a code refactoring as a way to reduce risk and improve the turnaround time for change requests. She restructures the code to reduce duplication and to make classes and methods a reasonable size. She also structures the code with the aim of making it easier to add and update products as this is the most common type of change to the system. A simple product can now be added to the system with a few lines of code.
This is the complete list of articles we have written about software design.
If you enjoyed this page, please consider bookmarking Simplicable.
© 2010-2023 Simplicable. All Rights Reserved. Reproduction of materials found on this site, in any form, without explicit permission is prohibited.
View credits & copyrights or citation information for this page.