A personal perspective of refactoring – Bill Griswold

This talk is the same as the one Bill gave at the refactoirng workshop at ICSE ’11, but since I was not live blogging then, this is a great opportunity for me to capture it anyway. I should have some note in a paper notebook on this talk (but who know’s where they are) And I remember it, because it was the talk that got me really interested in refactoring.

Bill tells that in 1987, his advisor David Notkin first noticed that software that is written from scratch will differ from software that is being extended.

At the same time, Tony Hoare had the idea that ‘each program, not involving recursion, can be rewritten to a normal form’ (The laws of programming) From this, Bill got the ideas that:

* There is an algebra for programs (source to source)
* The normal-form concept implies that all possible designs of a program can be reached by algebraic transformations

Then, you can make extended programs look like they were designed from scratch.

Bill used the program dependence graph (PDG) of which the semantics were just described, to determine equivalence. A transformation then must preserve the flow, and the values in the flow, and not introduce new flows.

Initially, Bill thought to apply the transformation directly on the PDG (Left figure) but then you had to get from a PDG to code which is hard. The other option was to generate the PDG twice, but that is very expensive. Finally he decided to save the transformation (right figure) and apply in on both sides.20140521_093632

So, what language to implement this ‘on’? First, BIll considered OO, but he choose Scheme. And what language to implement ‘in’ Common Lisp.

While Bill was finishing up his dissertation, he found the paper ‘Refactoring: an aid in designing application frameworks and evolving object-oriented systems’ First he worried that he had to start over, but it turned out the work was complementary. And, Bill cites David Parnas here ‘the wheel is reinvented many times, because it is a good idea. You should be worried about the soundness of ideas that were only invented once’

Together with his student Robert Bowdidge, Bill started to work on a user interface for refactoring. They found that the source code is not necessarily the best way to look at source code for the goal of refactoring. Therefore, they came up with the ‘star diagram’ that visualizes the underlying structure.

The refactoring user interface, with a star diagram in the middle.

The refactoring user interface, with a star diagram in the middle.

They performed a few user studies, which showed that the star diagram was more effective at planning a refactoring. In the studies they used ‘constructive interaction’ where people were pair programming and Bill and Robert transcribed what they said, to make the interaction more natural (cool technique!)