are there any objective complexity measures for APIs

No, pretty much all of them are arbitrary to one degree or another. I think complexity is a really hard thing to measure for APIs. For instance a complex problem domain will necessitate a complex API and that is a good thing. IMO, a simple API over a complex problem domain very rarely works. It is either not powerful enough, because the compromises the author had to make for the sake of simplicity removed too many features/options. Or it is actually more complex because the author applied their own personal world-view/metaphor-model to the problem domain and you have to understand that before you can even think about using the API itself.

Personally I have always been a fan of consistency being a good way to manage complexity in APIs. A few years ago I got a book called Reusable Software : The Base Object-Oriented Component Libraries by Bertrand Meyer off of eBay. It sat on my shelf for a while until I found myself needing to write a large-ish set of libraries for $work, and not having any clue how to approach it. The book has lots of really good advice, but the thing that stuck with me the most was the idea of using consistency as a way of managing complexity. Not only consistency in class, method and variable names, but consistency in abstractions as well. Meaning that similar concepts should be broken down in similar ways and provide similar features.

A side effect of consistency is also that it can breed habitual behavior. Around the same time I read The Humane Interface by Jef Raskin and The Invisible Computer by Donald Norman, neither of which are about APIs, but whose deeper messages can be applied to API design. The core ideas I took away from them was that a good interface is one whose use can become habitual, thereby moving from a conscious act to a (partially) subconscious act. This is not to be mistaken for "intuitive" which basically means "well it makes sense to me, what are you so stupid that you don't get this". To me a habitual API is one where after using it for a while it becomes possible to make educated guesses and have them be correct a fair portion of the time.

-stvn

In reply to Re: API complexity measures by stvn
in thread API complexity measures by zby

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.