Re:Good code needs few unit tests
by Confusion on Saturday March 20, 2010 @05:46AM
(#1206256)
The simplest abstraction of many interfaces is two methods:
The API is small, not complex and the amount of state is small, given that parameters are only set right before a call, all parameters are cleared after every call and no other state is retained. Yet it's clear to anyone that this isn't a good abstraction and that it doesn't result in an implementation that requires few unit tests. It requires an immense amount of documentation and allows a great many variations that yield bad/unexpected results.
Abstractions don't have unit tests: implementations have unit tests. It's the size and complexity of the implementation made possible by the abstraction that matters.
[ Parent
| on HN ]
That interface is certainly inconvenient to use, and potentially quite dangerous without a clearParameters().
It's not at all a rebuttal of the article, though. The article points out that the number of unit tests a design requires is larger for more complicated designs. An interface like yours would require no fewer tests than another interface exposing the same functionality using conventional function calls.