20 December 2009

Coding: An Outside in Observation | Javalobby

Coding: An Outside in Observation | Javalobby
it's important to drive the design of an API based on the way that it will be used by its clients:

"A great way to get usable APIs is to let the customer (namely, the caller) write the function signature, and to give that signature to a programmer to implement. This step alone eliminates at least half of poor APIs: too often, the implementers of APIs never use their own creations, with disastrous consequences for usability"

This is similar to Michael Feathers' Golden Rule of API Design:

"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"

When we don't do this we start guessing how we think things might be used and we end up with generic solutions which solve many potential use cases in an average to poor way and none of them in a good way.