API Patch

From APIDesign

Revision as of 07:26, 18 April 2010 by JaroslavTulach (Talk | contribs)
Jump to: navigation, search

The Teamwork chapter claims that maintaining an API is no harder than maintaining the same code without API. The essential precondition in such claim is that there are no bugs in already released API. The details can be found in the Chapter 16, here is description of related adventures.

Paying More Attention to Your Issues

Recently I've been given the privilege to become default owner of many NetBeans platform APIs including openide.nodes, openide.explorer, openide.loaders, openide.filesystems, and others (I deserve that, I've created them back in 1997). However I've also received 200 new bugs. This does not make me feel comfortable. In such huge amount of issues, it is almost impossible to realize that some new arrived. It is impossible to really deal with the issues. At best they lay around unnoticed. I don't think this is good destiny for a bug report, and thus I decided to reduce their number significantly.

I went through the issues and eliminated those which did not seem important. Of course I fixed trivial NullPointerException, etc. On the other hand, reports about improper behavior without an automated test had to be closed. Enhancements without patches too. You may find this impolite, but this is the only way to scale the development. If you really want an enhancement to be implemented, we have API Review process that allows you to contribute.

The number of API issues will get down to manageable level in a few weeks. When we get there, it will be possible to pay more attention to reported inquiries and deal with them in more polite way. Issues shall not be left laying around for few releases unnoticed anymore. At the end we shall all benefit from the radical elimination of the number of open issues in NetBeans APIs.

No Bugs in Already Released APIs

The above attitude can probably only be applied to APIs (although similar attempts may be observed in Agile movement too). We can expect those reporting nontrivial issues against API to have some level of engagement (e.g. be able to write a code and/or test). However if you provide end user functionality you may need to treat your users differently.

However in an API (where BackwardCompatibility is the primary concern), there either trivial bugs (exceptions at unexpected places) or there are features. After a release (due to the BackwardCompatibility implications) every bug turns into a feature.

As such reproducing and fixing a bug in an API requires different attitudes. Encouraging community to seek for bugs in an API and provide patches to its behavior is a best way to make the API really usable. On the other hand, the maintainer needs to be careful to not accept bad patches. The chapter 16 describes strategies to evaluate quality of submitted patches and separate the perils from dust. But the rules are simple an API bug report has to be good:

  • it has to be easy to verify the problem is there - the best way to do it is to have an automated test that can just be executed and the misbehavior reveals itself automatically
  • when the fix is applied (and subsequent changes are made in future) one can easily verify that the original intentions are still valid - again automatic test is your best friend
  • the change needs to be cool - well, API writers are glad to accept patches, if they are good (notice the self reference in the definition).

Accepting Unacceptable

There is a little coding trick, called code injection, that can help balance the need for extensibility while lowering overall Cost of Ownership. While using API CodeInjection it is basically possible to donate API Patch to any API.


<comments/>

Personal tools
buy