Slashdot Mirror


HOWTO Document and Write an SDK?

jmwmit asks: "A startup that I am working with is looking to write its first SDKs - one public for community developers and one for 3rd party commercial developers. What is the Slashdot recommended or preferred format for SDK documentation, both the code APIs and the general docs? What great SDK examples have people used in the past and would recommend as good models? What do Slashdot developers consider absolutely necessary features in an SDK, regardless of the application?"

26 of 78 comments (clear)

  1. Think about it by l0rd · · Score: 4, Insightful

    Just think long and hard when you design it. There's nothing annoying than having to overhaul your code becuase a function/class syntax has been changed.

    1. Re:Think about it by jgrahn · · Score: 2, Insightful
      Just think long and hard when you design it. There's nothing annoying than having to overhaul your code becuase a function/class syntax has been changed.

      And don't just think -- use the thing for real-life work yourselves. I cannot see how one can come up with a good interface without that feedback.

  2. What helps me by secondsun · · Score: 4, Interesting

    What makes a good SDK is decent documentation and design. What makes an excellent SDK is well though out designs and very detailed documentation. Code examples, comments, descriptions of functions functions, parameters, and return values.

    Sun has done a wonderful job with java and documentation. The only thing that I would like to see added to it would be links to items that reference each function/object.

    A project that has done an awful job at documentation and design is Squeak. There is little documentation and almost every function imaginable is in the Object superclass.

    --
    There is nothing wrong with being gay. It's getting caught where the trouble lies.
    1. Re:What helps me by yasth · · Score: 2, Insightful

      Not just code examples but both non trivial examples and trivial examples. A reference application allows the developer to see how the design fits together (and can be used to test the viability of the design), while trivial examples allow copy and paste programming which on some projects is deadline dictated.

      Sun's documentation is very well done. What is more is most of the various add ons are well documented, Javadoc really works well.

      Also it helps a lot to have a nice quick start. Really look at what a lot of embeded systems companies have done lately, there is a serious push to do everything possible to just let the develepor to get on with life. Mostly it is just detailed documentation, just add water examples, and lots of communication (i.e. if you are having trouble with something you will end up speaking to the engineer who did that section.).

      --
      I'd do something interesting, but my server can't handle a slashdotting.
    2. Re:What helps me by Software · · Score: 2, Informative
      JavaDoc is nice, but Sun discourages the use of sample code in JavaDoc. For this reason, I find JavaDoc less useful than Microsoft's MSDN documentation or the documentation typical of a Perl module. JavaDoc is good when you can't remember some detail about the object or method you're using, but it's not good when you're just starting out. Sun would say, "That's what a tutorial is for! JavaDoc is an API reference, not a tutorial.", but why not have both?

      Sun's guide to writing JavaDoc has lots of good ideas, regardless. As does Sun's guide to API specs.

    3. Re:What helps me by pavon · · Score: 2, Informative

      There are two things needed to learn a new system quickly - a good reference giving the details of every function in the SDK, and documents giving the big picture. The former is pretty easy to understand how to do well and there are good tools like javadoc or Doxygen that help with this task.

      The latter is the one that is lacking most often. You can see very quickly whether a geek or technical writer was in charge of the documentation. If it was a geek this document is non-existent, and at best you have few code examples to help you get the big picture.

      If it was done by technical writers it is extremely verbose, baby-stepping you through everything. This is something that mangers have a hard time understanding - if documentation is so overwhelming that it is faster and easer to learn by jumping into the code, then you are not much better off than when you had no documentation at all.

      My suggestion would be to write a document that you would like to read. Give a quick overview of the organization / concepts of your libraries, and then quick code examples demonstrating how they fit together. If there is something that seems to verbose, or explains things that every computer programmer should know, either take it out or maintain two documents - the "expert" overview and the tutorial.

      If there are any common pitfalls/misconceptions with your SDK (and you can't change the SDK to improve the situation) make sure they are in there. It is sometimes hard to write this yourself as you are already familiar with the SDK, and so you may not think to put down some things. For this reason, you should get help from people who are programmers but are not familiar with the SDK yet and/or are in the process of learning it. If there are any common questions, that means the documentation is lacking in that area. And of course this does not supersede the need for more in-depth (and well commented) code examples.

    4. Re:What helps me by ievans · · Score: 2, Informative

      They usually do provide both. I work on the J2EE Tutorial, which documents the APIs included in the J2EE platform. There's also the Java Tutorial, which documents the standard JDK/JRE platform APIs. For other APIs, check the BluePrints or other tutorials & code camps. Not to mention the case studies and the code samples bundled with other distributions.

      The problem with including tutorial or extensive sample material in API documentation is it's too disparate, and not useful when dealing with more complex applications that use a number of APIs. If you're writing a servlet that uses JDBC to pull data from a database, where does the sample code go?

      -ian

  3. Documentation formats by n1ywb · · Score: 2, Interesting

    You need to use a documentation framework to automate the process, unless your SDK only has one or two functions. I like Doxygen a lot, it's pretty easy to use and works with lots of languages. JavaDoc or PerlDoc, etc are good for specific languages. Html is a fine file format for the final output.

    --
    -73, de n1ywb
    www.n1ywb.com
  4. Who's your expected audience? by JavaRob · · Score: 4, Insightful

    Tough one to answer without more info....

    Is this an SDK for developers using your own invented language, with compiler etc.?

    What other language or environment is it most like? Those are the developers who will feel most comfortable developing with it, so you should model the documentation on standard docs for that language.

    General advice -- people learn new things best by doing them. Make sure your docs have a very quick intro to give developers the lay of the land and get them interested, then jump right into getting the full-source, good functionality demos running. The sooner I can create something actually useful to me (probably by modifying your sample app, not coding something from scratch), the sooner I'm hooked.

    Then to *keep* me hooked, you'll need a very thorough, easy-to-use reference -- both language elements and error codes/messages. It should have a good index, but also be organized well into good , fairly fine-grained categories (so that I can find what I need when I want to do X even though I don't know the function, etc.).

  5. Qt by Otter · · Score: 3, Informative

    TrollTech did a superb job with Qt. Excellent balance of documentation, examples, tutorials and overviews.

  6. Definitions AND examples by samjam · · Score: 4, Interesting

    You need good examples to SHOW what your definitions mean.

    You need good definitions and specifications so developers can extend the given examples to their own situation.

    Each new class of capability for a given module will need some examples. Too many trivial examples and not enough meaty examples driver developers mad with rage.

    If your SDK has well defined uses, tell a story of a developer writing and refining some code for a given purpose, so the reader can see how and why the more subtle points of the APIs are important.

    The PERL 4 Camel book is a good example of this.

    Sam

  7. Errors that mean something by ka9dgx · · Score: 4, Insightful
    If you return an error, make it unique for each actually error source. Resist the temptation to group all the errors together. NEVER us a "general error"... your code knows why it failed, its criminal not to return that information to the calling program.

    There's nothing worse that some of the BDE errors from Borland. They're misleading at best, and they lie sometimes.

    Remember - The true measure of character is what you do when things go wrong.

    --Mike--

    1. Re:Errors that mean something by 1000101 · · Score: 2, Funny

      BDE errors are terrible to say the least. Here is my favorite: $2E3B : Query makes no sense.

  8. Write 1 by brandonY · · Score: 2, Insightful

    Maybe I misunderstood, and you're writing SDKs for two seperate things, but I highly recommend against writing two seperate SDKs for the same system. It more than doubles the effort. If you need to give your corporate users more power, offer extensions to the original SDK, so that the two are the same except for one extra bit. That way, corporate folks can use the other stuff, and the other folks know precisely what they're missing.

  9. Wiki... by dmayle · · Score: 4, Insightful

    One very bizarre, but incredibly helpful word for you: Wiki

    Even if you only do it in restricted form (verified commits on private site) you'll find that the volunteer work of all of your users will give you a much better final product than whatever you release. (Your users can even help out early of you do a release-early release-often model.

    You'll get to leverage the power of open-source (the community) because you have a know community already.

    On the same topic, something else you might want to provide are skeletons (working stubs that do nothing, but have all of the crap-work already done for starting projects), and a very simple, but fully functional project that takes advantage of the SDK, to show how you expect it to be used.

  10. Re:Slashdot standards? by smittyoneeach · · Score: 3, Insightful
    You can't write documentation without asserting something about the reader.
    Does "no clue" imply that this is the first time they've ever tried coding something?
    In this case, you want to write something gentle. The python tutorial is one notable example of what to do there.
    However, if you're talking boost, the 100-level stuff isn't going to win applause.
    One thing I haven't seen yet in this thread is the task-oriented, or 'cookbook' approach, that serves at least two distinct purposes:

    quick-n-dirty steps for the initiated

    nice feature overview, to highlight functionality you may not yet be using.
    Another thing unmentioned in the thread in indices. For documentation of size, the better the indices, the more useful.

    --
    Get thee glass eyes, and, like a scurvy politician, seem to see things thou dost not.--King Lear
  11. Re:Slashdot standards? by oojah · · Score: 3, Informative

    I felt this needed highlighting:

    I'm tired of reading documentation that's written like I already understand the system and only makes sense after you know what you're doing. If I already understood the system I wouldn't need docs.

    It's an excellent point - don't just document your API, tell us how to use it!

    Cheers,

    Roger
    --
    Do you have any better hostages?
  12. MSDN by Anonymous+Cowpart · · Score: 4, Insightful

    I must say that MSDN (Microsoft Developer Network) is a very good SDK,
    at least when considering the Platform SDK (albeit for a terribly inconsistent API).

    Search, Index, and cross-reference are all well-implemented, consistently formatted,
    and complete, and updated fairly often. Combined with a choice of format
    (HTML help or web browser of choice - even Firebird works well), it is a pleasure to use.

    1. Re:MSDN by The+Bungi · · Score: 2, Informative
      I've been writing Win32 code for 10 years and I've never seen "other flags" used there. And STACK_SIZE_PARAM_IS_A_RESERVATION is rarely used because it's safer to just set the stack reserve in the app's image header, though that is supported under WinXP/2003. You usually use CREATE_SUSPENDED, and even that is rare.

      What other flags have you seen used?

  13. Cross-language conversions by Arrowhead · · Score: 2, Insightful

    You haven't said which programming language the SDK is in, but one thing that makes a bad SDK is one that's a literal translation from an API in a different language.

    Case in point:
    A Java API for a commercial product is based on the earlier C API. All the magic handles are properly translated to objects, but sometimes the internals stick out. It has a method you can (or, as it turns out: must) call to set the character encoding the library uses to communicate with the server. This makes sense for C, which needs to be told, but if all of your Java API uses Strings, a method like this is nothing more than a please don't suck method you have to call, or things fail.

  14. Documentation by rbarreira · · Score: 2, Insightful

    Make documentation in such a way that programmers which have already your API's before (or similar ones) don't have to read the whole manpage/docpage for a given function in order to know some detail.

    This might involve some redundancy, but I prefer it that way. For example, the good linux manpages are usually separated by sections (description, return values, etc). If I'm already familiar with, say, the recv call, I don't want to read through the whole manpage in order to know what the function returns when the remote host has shutdown the connection. I simply go to the "return values" section and everything is possibly repeated there.

    And the most important - don't let your documentation rot as the API is updated...

    --

    The AACS key is NOT 0xF606EEFD628B1CA427BEA93A9CA9773F
  15. Good analogies and metaphors by slimemold · · Score: 2, Informative
    Any time you are trying to explain something, you have to bridge the gap between what they already know and understand, and what they need to know and understand.

    When a programmer first learns about data structures, s/he might learn about "trees". Imagine explaining a tree without the implicit metaphor of roots, branches, and leaves. Sure, you could do it, but not without a lot of pain. Maybe it would be a "pointer-based hierarchical polyfurcating network of arbitrary data nodes".

    But it goes beyond just explaining the concept. If your analogy is any good, many items are, at a basic level, self-documenting. A debugger or profiler, for instance, uses the analogy of a VCR. You already know what the play, pause, and stop buttons are likely to do. You might consult the docs to see what exactly the difference is between pause and stop, but whatever it is it won't be a big surprise.

  16. My perfect SDK by Tom7 · · Score: 2, Insightful

    The perfect SDK, to me, has a "two faced" nature. The first face is a dumbed-down thing that makes it easy to get started, or to use some shallow function of the SDK as part of a project that's mostly focused on something else.

    1. It should be easy to do an obvious thing with the SDK, without reading the whole manual. ... it should come with an example, or set of examples, that compile right out of the
    box and are maximally simple. ... the interfaces should use base types as much as possible (strings, arrays of bytes,
    filenames) to make them easier to invoke, even if this is not general enough for
    all purposes. ... the user shouldn't have to install many dependencies for aspects of the SDK he isn't going
    to use.

    The second face exposes you to all the details, and the maximal generality. Here, reader and writer objects (or whatever is appropriate for your language) take the place of files and byte arrays, unicode support is standard, etc. Generally the first part is just stubs around this.

    In my opinion, there's no reason to provide middle ground, and it tends to clutter the interface.

    IMO, the SDL is a good example of a well-designed SDK.

  17. MySQL, and *use it* before publishing! by TTK+Ciar · · Score: 2, Informative

    I have often looked to MySQL's html documentation as a shining example of what documentation should be like. It has a pretty good API, too. I usually haven't the time to do a really knock-up job of my own documentation, but I do try to look at MySQL's for my general approach, including the format (html). Here's an example of some of my documentation. I borrowed some pointers from the standard UNIX man page format, too, because it's been in use for a long time and developed into something reasonably complete and useful.

    Another good example (imo) is the RFC which defines the NNTP protocol, rfc-977.

    Know your audience -- the HOWTO I wrote was primarily for nonprogrammers with rudimentary knowledge of UNIX command line use (waybackup's primary expected users), but also for programmers who might be trying to debug or extend my code.

    The most important thing with a SDK or any other tool, in my opinion, is use it a lot before publishing it, or even considering its development complete. Don't just come up with artificial examples, but actually use it internally to solve real-world problems. Your developers will unavoidingly find really annoying little problems in need of fixing, and come up with time-saving functions (perhaps just wrappers around already-existing API functions) which might need to be added to the SDK. Perhaps there's a function which seemed reasonable at the time, but in actual practice leads to runaway memory consumption. Maybe there are several functions which often get used together, but require the programmer to keep track of parameters which could get hidden internally instead. A nice long beta test, with the expectation of many programmer hours spent in reaction to user-reported errors/suggestions, is also often a good thing.

    In fact, as a programmer I usually tailor my development effort towards getting something minimally useful first, and then actually use it, and let my use define further development. Features that sound good "on paper" are often a waste of time to develop because they don't actually get used. Also, thinking real hard at code does not necessarily make it better than code which has been shaped by real-world usage.

    Anyway, I'll shut up now. Good luck with your SDK!

    -- TTK

  18. Provide a test harness by chriseyre2000 · · Score: 2, Insightful

    Provide a test harness (with source) that executes the api. Provide a debug stubbed version of the api that returns hints as to why the parameters failed. Be very clear on calling conventions. Who should allocate and free the memory. Be very careful when you pass out handles to records what they are for.

  19. Use patterns! by don.g · · Score: 2, Insightful

    Assuming that by SDK you really mean "some sort of framework", you should read the Documenting Frameworks Using Patterns paper.

    The approach they describe works quite well, and is easy to do incrementally, and easy to use for developers. Of course, you still want reference documentation for individual modules/methods/functions, but that's not going to be much use by itself.

    --
    Pretend that something especially witty is here. Thanks.