I don't keep my appreciation for Qt secret. Since I started using it this year, I consider it the best-designed API I've ever used. And this is in C++, a language notorious for its complexity...

These guys just keep improving. For their recent Qt version 4, they re-thought many of the design decisions taken when making the earlier APIs and made many improvements. They've also released a short & informative article - Designing Qt-Style C++ APIs. Many words of wisdom in it, here are some good quotes:

An API is to the programmer what a GUI is to the end-user. The 'P' in API stands for "Programmer", not "Program", to highlight the fact that APIs are used by programmers, who are humans.

As with other design work, you should apply the principle of least surprise. Make common tasks easy. Rare tasks should be possible but not the focus.

That just sounds like Perl's design goals :-)

Boolean parameters often lead to unreadable code. [...] An obvious solution is to replace the bool parameters with enum types.

do not abbreviate. Even obvious abbreviations such as "prev" for "previous" don't pay off in the long run, because the user must remember which words are abbreviated.

The number one rule of function naming is that it should be clear from the name whether the function has side-effects or not.


Comments

comments powered by Disqus