Skip to main content

Tidying: New Interface, Old Implementation


Excerpts from Tidying: New Interface, Old Implementation by Kent Beck:

[I’m likely to delete this tidying because it is rarer & less clear. If you find it helpful, lmk & I’ll leave it in. I’m sending it out to all subscribers because I need an example.]

So you need to call a routine & the interface makes it difficult/complicated/confusing/tedious. Implement the interface you wish you could call & call it. Implement the new interface by simply calling the old one (you can inline the implementation later after migrating all other callers).

Creating a pass-through interface is the micro-scale essence of software design. I want to make some behavior change. If the design was like thus and so, making that change would be easy(-er). So make the design like that.

The same impulse is true whether we are:

  • Coding backwards—start with the last line of a routine as if you already had all the intermediate results you needed.
  • Coding test-first—start with the test that needs to pass.
  • Designing helpers—if only I had a routine, object, service that did XXX then the rest of this would be easy.

[really really needs an example]