[Development] Views

Mutz, Marc marc at kdab.com
Mon May 20 22:48:29 CEST 2019


On 2019-05-20 22:18, André Pönitz wrote:
> On Fri, May 17, 2019 at 10:17:10AM +0200, Mutz, Marc via Development 
> wrote:
>> [...] There is no readability difference between the use of a Qt 
>> container and
>> that of an STL container.
> 
> Exhibit A:
> 
>      foo().contains(x)
> 
> 
> Exhibit B:
> 
>      {
>          ... container = foo();
>          std::find(container.begin(), container.end(), x) != 
> container.end();
>      }

And now do the same thing when you look for a given property's value: 
[name](auto &e) { return e.name(); }

This is called Selective Perception.

Here's another one:

Exhibit A:

     for (auto &[key, value] : map)
         use(key, value);

Exhibit B:

     for (auto it = map.cbegin(), end = map.cend(); it != end; ++it)
         use(it.key(), it.value());

Thanks,
Marc


More information about the Development mailing list