[Development] Views

Mutz, Marc marc at kdab.com
Thu Jun 6 16:51:46 CEST 2019


On 2019-06-06 15:49, Lars Knoll wrote:
>> On 6 Jun 2019, at 15:36, Mutz, Marc via Development 
>> <development at qt-project.org> wrote:
>> 
>> On 2019-06-06 15:14, Konstantin Tokarev wrote:
>> [...]
>>> There is a principle of single level of abstraction [1], and inline
>>> implementation
>>> of flat map can be viewed of violation of such principle. If flat map
>>> implementations
>>> were kept speparately, it would indeed make code easier to read and 
>>> maintain.
>>> [1] http://principles-wiki.net/principles:single_level_of_abstraction
>> 
>> The code factors the setting and lookup into functions already. A 
>> function is an abstraction. If you're concerned about a function that 
>> calls find_if and then uses the result, how do you rate this one: 
>> https://code.woboq.org/qt5/qtbase/src/widgets/kernel/qgesturemanager.cpp.html#_ZN15QGestureManager26filterEventThroughContextsERK9QMultiMapIP7QObjectN2Qt11GestureTypeEEP6QEvent
>> 
>> It's using _all_ the nice abstractions!
>> 
>> Puts some stuff into perspective, doesn't it?
> 
> Yes, the code in QGestureManager sucks. Basically because it abuses
> our data structures in a really bad way.
> 
> But let’s not use the worst example you can find in Qt’s code base as
> a comparison. Unmaintainable code in one place doesn’t justify doing
> whatever you want in other places.

IMO, the code sucks because it conflates algorithms and data structures. 
Wirth's book, however, is called Algorihms + Data Structures = 
Programmes, not Data Structures = Programmes. Yet, that is exactly what 
I feel is asked of me here: to hide the algorithms in a data structure. 
But the end consequence of this is ... qgesturemanager.cpp.



More information about the Development mailing list