Testable Abstraction

From the WorkingEffectivelyWithLegacyCode MailingList:

One dependency breaking technique that I'm having trouble naming goes like this:

You have a class with many dependencies. Only part of it needs to be under test to make the changes you need, so extract a superclass that contains those features and make it abstract by suppling only protected constructors. Then make a concrete subclass of it with a public constructor. Test that class. I learned the technique from JacqueMorel?, but we haven't come up with a nice name for it yet. By its mechanics, it is very similar to 'ExtractSuperclass' but the intent is different.

--MichaelFeathers

Interesting. I encountered a similar situation today while teaching a TestDrivenDevelopment class. I vote for "TestableAbstraction".

--RobertCecilMartin


CategoryAbstraction


EditText of this page (last edited November 30, 2004) or FindPage with title or text search