开发者

Best practices when designing an API

开发者 https://www.devze.com 2023-01-20 15:06 出处:网络
I am designing an internal API for a system I am writing. What 开发者_高级运维are some best practises in API Design to think about?The examples are in Java but the hints apply to any language.

I am designing an internal API for a system I am writing. What 开发者_高级运维are some best practises in API Design to think about?


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

How To Design A Good API And Why It Matters


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.


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
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号