Top ten principles of excellent API Design-IT education for Brothers

Source: Internet
Author: User
: This article mainly introduces the top ten principles of excellent API Design-IT education for brothers. if you are interested in PHP tutorials, please refer to them. Top ten principles of excellent API Design-IT education for Brothers
Each software developer uses APIs. The "excellent" API design is like magic. However, I don't know how many people can explain why some APIs are complicated and difficult to learn, while others are clean, simple, and easy to use. I will answer this question in this article and provide ten rules for excellent API design.
1. only what you need today
This is the top-level rule. Only solve the problems that must be solved today and minimize the answers to be completed. The temptation to solve tomorrow's problems is enormous. But you must resist the temptation! Do not release code in advance, but focus on narrowing down the release cycle. If it takes several hours to answer new questions, you don't have to guess what will happen tomorrow.
2. API modularization
Converts a large problem into a small one that can be solved independently. Modular APIs are easier to learn and can change over time. You can use a new module to replace the old one. You can teach the module one by one. You can also separate the experiment part of the API from the stable or traditional part.
3. use structured syntax
Use structured API syntax: Use thing. action or thing. property to replace do_action_with_thing. The syntax will naturally adapt to the modular method, where each module is a class.
4. use natural semantics
Do not create new concepts. Use only the well-known concepts of developers as the basis of class systems. If you find that you need to explain the concept, it indicates that you have made an error: either you are solving the problem in the future or you are building an API incorrectly.
5. API self-agreement
Each class must strictly use the same style and conventions. Consistency means that when a person learns this class, he can master all classes in an integrated manner. Documented conventions make them a required standard for contributors.
6. API scalability
Scalability has many benefits, not just because it is welcomed by contributors. It also allows you to delay implementation, because "if necessary, it is very convenient to add it later ". This is a win-win situation.
7. full test
Each class and method must undergo a complete test of malicious code. Write a test like writing code, and then use the test like an API provides to external conventions. Run these tests whenever the code changes. Do not worry about code coverage. What is important is external conventions. You can also consider using the agreed life cycle.
8. layered growth
Keep APIs focused, and then layer new APIs at the top so that they can grow over time. Scalability does not mean an indefinite growth. Define the scope of the API and execute it within the scope.
9. easy to use
The final test depends on the ease of use of the API. Can the example you wrote make your code look simpler? Are you forcing users to explain what they don't care about? Is there any additional step of no value? Focus on reducing the visible area of the API.
10. portability
Do not expose system concepts to APIs. Clean and purposeful abstraction: This API can run on any operating system. The API must be able to hide the implementation, but pay attention to the 4th rules and use natural abstraction.
Get the LAMP brother's original PHP video tutorial CD/detailed PHP Essentials edition for free. for details, contact the customer service on the official website:
Http://www.lampbrother.net
[IT education] video tutorials (courseware + Notes + video) on PHP, Linux, HTML5, UI, and Android are available )!
Network disk tutorial Download: http://pan.baidu.com/s/1mg8ANMg

The above describes the top ten principles of excellent API Design-IT education for brothers, including some content, and hopes to help those who are interested in PHP tutorials.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.