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?


References

  1. If the equation doesn’t render for you: <img title=“refactoring-objective-function” alt=“refactoring-objective-function.png” width=“80%” src="/img/refactoring-objective-function.png" /> ↩︎