A RefactoringNose is a common idea brewing on the xpdeveloper website:
http://www.xpdeveloper.com/cgi-bin/wiki.cgi?
The basic idea is that refactoring tools are here that can do the refactorings if we agree to them.
Now we need the same or new refactoring tools that can suggest refactorings in the first place. I see these tools as Ant tasks which when combined with a CruiseControl -esque ModificationSet? can check the code that has changed against the entire codebase.
This would have a couple of benefits.
The first benefit would be a time saver for the duplication spotting. I think of refactoring as creative destruction of duplication in code, and most of the time the duplications are pretty simple at the outset.
The refactorings I start to see later may be more complicated (too complicated for a tool to spot maybe), but the point is that the seed for these is always something simple which should be spotted by a tool. Most of the time I refactor code that I have not written to get it into shape. A tool like this would allow me to spot the areas needing work.
The second benefit would be that refactorings over large projects would become possible. I have experienced scenarios where two teams develop the same frameworks that are well refactored within, but did not/could not communicate across the teams and so the frameworks do a lot of the same sorts of things.
A RefactoringNose would nip this in the bud if it was part of a continuous integration cycle.
What do other people think about this? I think that this is where Refactoring HAS to go to become scalable across the enterprise.
I could be wrong. -- NeilThorne?
You'll be interested in Automated support for program refactoring using invariants (http://pag.lcs.mit.edu/~mernst/pubs/invariants-refactor-abstract.html), then. -- DavidSaff
A new automated duplication-finding tool, DupTective, could be useful as part of an automated build system: every time a set of changes is checked in, they could be evaluated for duplication of existing code. For efficiency, DupTective could be extended to search for duplication only inside a given list of files.
Note that DupTective fits the "smell" metaphor: it can tell you which regions of code reek of duplication, but not exactly what other parts they're duplicating.