ArticleS. MichaelFeathers.
TheGoldenRuleOfApiDesign [add child]

The Golden Rule of API Design.


(trying to say this is the punchiest way that I can in the hope that the meme travels far..)


It's not enough to write tests for an API you develop, you have to write unit tests for code that uses your API.

When you do, you learn first-hand the hurdles that your users will have to overcome when they try to test their code independently.


 Sat, 27 May 2006 07:56:59, Nat,
What a great insight.

So... develop the API and, at the same time, develop example applications and demos that use the API test-first, and then feed that learning back into the API as you go.

I often do that, but I've never noticed what I was doing or realised the value of the practice before.
 Mon, 29 May 2006 01:29:26, MichaelFeathers, Thanks
It's just been something I've been dealing with a lot lately, APIs that make testing impossible. If only everyone was doing what you do you.
 Mon, 29 May 2006 02:20:45, Kelley Harris, ? Example or two?
Rings true. An example or two would help this reader internallize the rule more.
 Mon, 5 Jun 2006 06:16:21, Sagy Rozman, Why develop the API first?
We deal with this all the time. The way we do it is we don't implement the api we implement 2/3 example applications and derive the api as we go. That isn't always possible since there might be another team waiting for your api, but sometimes it is.
 Mon, 5 Jun 2006 10:57:00, Ryan Platte, Frameworks as abstractions
The Rails meme of "frameworks as abstractions" is good, but not enough for TDD -- this is exactly why. Nice one.
 Tue,, , 40