tags:

views:

52

answers:

3

Hi,

I am designing an internal API for a system I am writing. What are some best practises in API Design to think about?

Thanks

+1  A: 

Test Driven Development.

TDD will inform your design because it prompts you to ask questions like 'what do I need this to do' and it makes it easier for you to refactor with confidence, as you go thru your revisions. It also encourages making things as simple as possible, which is always a good thing.

hvgotcodes
Anachronistic? As in from the future? :) I upvoted him although I reckon that TDD alone doesn't mean the recipe for success. Experience is necessary, but TDD can help a lot in designing the API, because you're forced to exercise that API. Another thing that I'd do is to TDD an application that uses that API.
Ionuț G. Stan
@mike, that word, I do not think it means what you thing it means ;)
hvgotcodes
@Ionut, there is no sure-fire way for success. But TDD can only help, in many different ways..
hvgotcodes
I agree it can help, and that it's a best practice in general, although not really specific to API-development. However, APIs should indeed have good testing frameworks and ideally these interface tests should be written before the API implementation is begun.
Joe
+1  A: 

Just remember that an API is a user interface. I try to focus on

  • doing one thing well,
  • maintaining a useful power-to-weight ratio,
  • avoiding cryptic names, and
  • explicitly specifying behavior via tests and effective documentation
Joe
Do you mean developer interface? *Application* Programming Interfaces are not directly used by the end user.
John K
Application programmers are people, too :) When they are using an application programming interface, they are "users" of that programming interface. Names, documentation, and minimizing access are all very important in designing APIs.
Joe
+1 to counter. The term UI maybe overloaded but the intent is clear. Everything has users - microprocessors, programming languages, frameworks, libraries; regardless of whatever professional name we give those users.
Anurag
+2  A: 

The examples are in Java but the hints apply to any language.

How To Design A Good API And Why It Matters

Helper Method