Software engineering
Refactoring.
Improving the internal structure of existing code while preserving its observable behavior.
Useful when the design needs work but the behavior should stay stable.
“Refactor the validation code into one module while preserving all accepted inputs and error messages.”
A closer look
Small transformations can make code easier to understand and change without adding a feature. Define the observable behavior worth preserving, including errors and edge cases. Tests give feedback during the work, although passing tests alone cannot prove every behavior is unchanged.
Put it to work
“Extract the repeated calculation into a named function, keeping the same rounding behavior.”
A useful distinction
Changing business rules while reorganizing code is a behavior change as well as restructuring. Describe both instead of calling the entire change refactoring.