English 中文(简体)
A. 编写APIC/CMP.1号文件的建议
原标题:Recommendations for writing an API
最佳回答
问题回答

I don t think the language-agnostic tag is appropriate for this question, and moreover, it needs a specific language tag. Designing a good API requires a consideration of the characteristics and idioms of the language you re working with. Some of the most important considerations:

  • whether memory is managed manually, with RAII, or with garbage collection.
  • support for generic programming, object oriented programming, functional programming, etc. in the language.
  • what type system the language uses.

So the best piece of advice I can offer to your question as it stands (language-agnostic) is not to assume there are language-agnostic universal API design guidelines, and instead get to know the language(s) you re working with and the appropriate idioms.

  1. API must be clear Easy to learn Easy to use, even without documentation Hard to misuse Functionality should be easy to explain Names should be largely self-explanatory Names should be consistent: the same word should mean the same thing through the whole API API should be regular, have some symmetry

给予信贷

http://sharismlab.com/blog/2012/07/21/how-to-write-an-api-for-your-web-app/

Understand how users are going to use your application. If you can able to note down all the usecases of your application then you can implement each usecase as part of API. At the end of the day you will have an API which provides set of usecases that you decided. Further you should able to extend API with expansion of usecases and should be able to maintain backward compatibility.

API implementation for Web services:
Decide which protocol, data formats and authentication you need to use.
Most of the web services implement API with following parameters.

Protocol: HTTP
Dataformat : JSON/XML
Authentication : API key/Oauth

API implementation for libraries and SDK:
Create prototypes which should be frozen through out life.
Expand API by adding extra functions and do not change existing functions prototypes.
Allow users to provide as many inputs they can as arguments to functions. So the application can do its job as user requested to do.

Keep user in mind and API should allow user to use it with minimum effort.

Refer:
An Introduction to APIs : https://zapier.com/learn/apis





相关问题
XML-RPC Standard and XML Data Type

I was looking at XML-RPC for a project. And correct me if I m wrong, but it seems like XML-RPC has no XML datatype. Are you supposed to pass as a string? or something else? Am I missing something? ...

Is it exists any "rss hosting" with API for creating feeds

I am creating a desktop app that will create some reports. I want to export these reports as RSS or ATOM feeds. I can easily create feeds with Rome lib for Java. But I have no idea how to spread them. ...

Improving Q-Learning

I am currently using Q-Learning to try to teach a bot how to move in a room filled with walls/obstacles. It must start in any place in the room and get to the goal state(this might be, to the tile ...

High-traffic, Highly-secure web API, what language? [closed]

If you were planning on building a high-traffic, very secure site what language would you use? For example, if you were planning on say building an authorize.net-scale site, that had to handle tons ...

Def, Void, Function?

Recently, I ve been learning different programming langages, and come across many different names to initalize a function construct. For instance, ruby and python use the def keyword, and php and ...

热门标签