[Development] New Qt example development guideline and revamping examples

Giuseppe D'Angelo giuseppe.dangelo at kdab.com
Thu Jan 19 13:33:48 CET 2023


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.

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4244 bytes
Desc: Firma crittografica S/MIME
URL: <http://lists.qt-project.org/pipermail/development/attachments/20230119/1bb9cf93/attachment.bin>


More information about the Development mailing list