Jump to content
TheTime

Designing Better JavaScript APIs

Recommended Posts

Posted

At some point or another, you will find yourself writing JavaScript code that exceeds the couple of lines from a jQuery plugin. Your code will do a whole lot of things; it will (ideally) be used by many people who will approach your code differently. They have different needs, knowledge and expectations.

Pie-chart.jpg

This article covers the most important things that you will need to consider before and while writing your own utilities and libraries. We’ll focus on how to make your code accessible to other developers. A couple of topics will be touching upon jQuery for demonstration, yet this article is neither about jQuery nor about writing plugins for it.

Peter Drucker once said: “The computer is a moron.” Don’t write code for morons, write for humans! Let’s dive into designing the APIs that developers will love using.

TABLE OF CONTENTS

  1. Fluent Interface
  2. Consistency
  3. Handling Arguments
  4. Extensibility
  5. Hooks
  6. Generating Accessors
  7. The Reference Horror
  8. The Continuation Problem
  9. Handling Errors
  10. Going Asynchronous
  11. Debugging Fluent Interfaces
  12. Documenting APIs
  13. Conclusion

Sursa

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...