[Development] Use of Standard Library containers in Qt source code
mwoehlke.floss at gmail.com
Mon Jul 4 19:54:45 CEST 2016
On 2016-07-02 02:42, Marc Mutz wrote:
> The STL has a great API. push_back() / back() vs. append() / last(), e.g. It
> just happens to be largely consistent with itself instead of with Qt. But
> camelCase is not intrinsically "better" than underscored_names, and I also
> fail to see why first() should be intrinsically superior to front().
TBH, this is the fault of the English language :-). The words that Qt
uses for its API are more intuitive to English speakers, if less
consistent. The words STL uses are more logical¹ and consistent, but
I've never actually stopped to think about STL being logical¹; every
time I use it, it drives me nuts because the API is not "natural".
(¹ In the sense of "strictly conforming to formal logic".)
Consider... if I ask you what relation the letter 'A' has to the
alphabet, is it the letter *at the front*, or is it the *first* letter?
I bet you, and most (native, certainly) English speakers said it's the
*first* letter. STL's word choices are... a bit like writing code in
King James' English.
I do however feel that Qt's consistent use of verbs for actions and
non-verbs for properties (i.e. empty vs. isEmpty/is_empty) is far superior.
More information about the Development