API Design.ppt
《API Design.ppt》由会员分享,可在线阅读,更多相关《API Design.ppt(21页珍藏版)》请在麦多课文档分享上搜索。
1、API Design,CPSC 315 Programming Studio Spring 2009,Follows Kernighan and Pike, The Practice of Programming and Joshua Blochs Library-Centric Software Design 05 Keynote Talk: ”How to Design a Good API and Why It Matters”,API,Application Programming Interface Source code interface For library or OS Pr
2、ovides services to a program At its base, like a header file But, more complete,Why is API Design Important?,Company View Can be asset big user investment in learning and using Bad design can be source of long-term support problems Once used, its tough to change Especially if there are several users
3、 Public APIs One chance to get it right,Characteristics of Good APIs,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 Appropriate to audience,Designing an API,Gather requiremen
4、ts Dont gather solutions Extract true requirements Collect specific scenarios where it will be used Create short specification Consult with users to see whether it works Flesh it out over time Hints: Write plugins/use examples before fully designed and implemented Expect it to evolve,Broad Issues to
5、 Consider in Design,1. Interface The classes, methods, parameters, names 2. Resource Management How is memory, other resources dealt with 3. Error Handling What errors are caught and what is done Information Hiding How much detail is exposed Impacts all three of the above,1. Interface Principles,Sim
6、ple General Regular Predictable Robust Adaptable,Simple,Users have to understand! Do one thing and do it well Functionality should be easy to explain As small as possible, but never smaller Conceptual weight more important than providing all functionality Avoid long parameter lists Choose small set
7、of orthogonal primitives Dont provide 3 ways to do the same thing,General,Implementation can change, API cant Hide Information! Dont let implementation detail leak into API Minimize accessibility (e.g. private classes and members) Implementation details can confuse users Be aware of what is implemen
8、tation Dont overspecify behavior of modules Tuning parameters are suspect,Regular,Do the same thing the same way everywhere Related things should be achieved by related means Consistent parameter ordering, required inputs Functionality (return types, errors, resource management) Names matter Self ex
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
2000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- APIDESIGNPPT
