How to design a good API

The below is the summary of :

How to Design a Good API & Why it Matters

1 Characteristics of a Good API
-Easy to learn
-Easy to use, even without documentation
-Hard to misuse
-Easy to read and maintain code that uses it
-Sufficiently powerful to satisfy requirements
-Easy to extend

2 General principles

--API should do one thing and do it well  
       --Functionality should be easy to explain
       --If it's hard to name, that's generally a bad sign
       --Good names driver development

--API should be as small as possible but no smaller  
      --API should statsfy its requirements and be powerful.
      --When in doubt leave it out 
      --You can always add, but you can never remove
      --Constraints is acceptable. You won't be able to please everyone

 --Implementation should not impact API
      --Do not overspecify the behavior of methods.   
      --Free to change implemention at anytime
      --Dont't let implemention details "leak" into API

--API Must coexist peacefully with platform
      --Do what is customary
      --Take advantage of API-friendly features
      --Know and avoid API traps and pitfalls
      --Don't transliterate APIs

--Avoid Long Parameter Lists
       --Three or fewer parmater is ideal
       --Long lists of identically typed params harmful 

--Consider Performance Consequences of API Design Desicion.
       --be cautious of the mutability. Eg: resource needs to be allocated each time.

--Documentation Matters    
       --Document for functionality,  each parameters , expection and exception.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

一条叫做nemo的鱼

你的鼓励是我最大的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值