[Development] New Qt example development guideline and revamping examples
Elvis Stansvik
elvstone at gmail.com
Thu Jan 19 18:04:12 CET 2023
Den tors 19 jan. 2023 13:34Giuseppe D'Angelo via Development <
development at qt-project.org> skrev:
> Il 19/01/23 10:27, Tor Arne Vestbø ha scritto:
> >> All the contrary, do NOT do that, as it results in 200+ lines unnamed
> lambdas. Strongly prefer named slots. Keep the lambdas short and to the
> point. Do not use unnamed lambdas.
> > No, strongly prefer lambdas if they are within a reasonable size. No-one
> is arguing for 200+ line lambdas.
>
> The reason for such a harsh rule is that "reasonable size" tends to go
> out of control very quickly. Is 10 lines too much? Maybe 15? Giving it a
> fixed size opens up the door to a sorites paradox. The point is that
> when you write the lambda the first time, it'll be completely obvious
> what it does to you, even if it's long. You'll even avoid giving it a
> name and connect straight to it, as it makes "perfect sense", in the
> context of the code surrounding the lambda.
>
> But on the long run, this makes the code worse to read and understand.
> No one will understand what the lambda is _meant_ to do without
> analyzing the body of the lambda, line by line (cf.: a named
> lambda/slot, where a proper name tells you everything). And reasoning on
> the code surrounding the lambda is also much harder as it's intermingled
> with the lambda itself.
>
> If anything: the fact that this is seen as _questionable_ and people
> disagree on it should be a good indication that examples shouldn't do
> it, as examples shouldn't feature _questionable_ code styles.
>
Agree. Code base I'm working on now is starting to get infested with
"swollen" lambdas. Happens easier than you think.
Elvis
> My 2 c,
> --
> Giuseppe D'Angelo | giuseppe.dangelo at kdab.com | Senior Software Engineer
> KDAB (France) S.A.S., a KDAB Group company
> Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com
> KDAB - The Qt, C++ and OpenGL Experts
>
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> https://lists.qt-project.org/listinfo/development
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20230119/c64bb13a/attachment.htm>
More information about the Development
mailing list