3 ms·
Indeed, Qt is a great C++ API, although its design style is quite different from STL, boost and friends. In particular, Qt is a very good example of a well-des
by vog 14y ago
Indeed, Qt is a great C++ API, although its design style is quite different from STL, boost and friends.
In particular, Qt is a very good example of a well-designed exception-free API. That is, it doesn't make any use of exceptions, and yet you don't have to check for error code after each low-level operation.
For almost every class, Qr provides sensible "null-like" objects, i.e. they don't simply return stuff like NULL pointers, or JavaScript-like "null" objects that crash a bit later (when you try to access properties). You just get an object that behaves sane to the most possible extent, so mostly it simply doesn't matter to your code that some operation returned a null-like object. And in those rare cases where it does, you usually have to check later, and only once, in your code. You don't have to check after every single step.
This is quite hard to describe, but I think that sensible null-like objects make it possible to combine all advantages you usually get from using exceptions, without the disadvantages that arise from disrupting your control flow (which would make it harder for you to reason about your code and to ensure proper cleanup after each operation).
All in all, the Qt API taught me a lot about design concepts you usually don't find in other APIs.