25 — Search-Based Software Design¶
Driving question: When a design has many possible refactoring sequences, can optimization help choose among them?
Learning objectives¶
- Formulate refactoring as a search problem.
- Define solution representation, operators, objectives, and constraints.
- Explain Pareto optimization for competing quality goals.
- Identify fitness-function pathologies and search validity threats.
Search formulation¶
A candidate solution can be a sequence of refactorings:
\[
S = \langle r_1, r_2, \ldots, r_k \rangle
\]
Objectives might include minimizing coupling and complexity while maximizing cohesion/testability and minimizing transformation cost.
A multi-objective formulation avoids collapsing all qualities into an arbitrary weighted sum. The result may be a Pareto front of non-dominated alternatives.
Critical questions¶
- Are all generated refactorings valid and compilable?
- Does the metric objective actually reflect desired design quality?
- Is a large metric improvement produced by pathological transformations?
- How large is the search space?
- Are results stable across seeds?
- How much developer effort is needed to understand the recommended sequence?
Design / research exercise¶
Define an optimization formulation for refactoring a Java system using at least three competing objectives. Give one example of a metric-gaming solution your fitness function must prevent.
Suggested reading¶
- Search-Based Software Engineering literature.
- Research on multi-objective automated refactoring.