July 20, 2007
Refactorbot Discovers Better SolutionGuillaume Bertrand has come up with a program that has found a better solution to the OO design challenge.
There must be many, many thousands of ways of grouping 8 classes into 1-8 packages, so this is a very hard problem to solve with just pen and paper and my few remaining brain cells. Guillaume's algorithm must have crunched its way through many - if not all - of them, settling on the permutation with the best values for package cohesion and distance from the main sequence.
This is reminiscent of a chess computer crunching its way through sequences of moves looking for the one that offers the best strategic outcome.
In that sense, although perhaps not evolutionary - though maybe it was; Guillaume doesn't say - this is possibly the first example I've seen of an OO design problem being solved programatically. The world's first refactorbot? If you hooked this up to a tool like Resharper, it wouldn't be far off.
We can at least now look at what the metrics tell us is the optimum design solution and ask: is this really a better design? A fascinating way to test our understanding of design principles, and especially to test the design of our metrics.
Anyhoo, Guillaume has knocked my socks off with this impressive display of OO cleverness. If I had a project and a budget, I'd hire him in a heartbeat!
Posted 12 years, 1 month ago on July 20, 2007