An Objective Function for Code Refactoring

Have you ever set an objective function for code refactoring, where, for every proposed total change (e.g. reviewable pull request), you seek to maximize the change in this function? An example:1

\[ \log_2(pct_{LOC\_tested}) * pct_{importables\_documented} * pct_{LOC\_nostate} \over n_{LOC} \]

Good (numerator stuff):

Bad (denominator stuff):

What metrics correlate with code-refactoring success in your experience? These? Others?


  1. If the equation doesn’t render for you: refactoring-objective-function.png ↩︎