On Friday 03 June 2016 15:02:23 André Somers wrote: > > Then we don't need to talk about how to format multi-line ifs at all, > > because they do not exist anymore. > > Eh... So you move the same to a different method. How does that help? > You'd basically get the same expression but then in a method of it's own?
You have more freedom to format the code in the method. You can use a multi- line return statement, already an improvement over a multi-line if statement, or you can use guard clauses, possibly interspersed with comments... But the main advantage is that you replaced an ugly, unreadable construction with a *name*. We humans like to name things. E.g. I don't like unnamed lambdas. I think it's much preferable to assign a lambda to an auto variable than to inline it into the expression, precisely because it drives people crazy when they need to come up with a name (hi, Anton :). But that mental effort expended by that one person (and their reviewers, hi Eddy) is saved for everyone else (iff the name chosen is descriptive). As Fowler argues in Refactoring, sometimes the Smell is so bad that you Extract Method even if the result is longer _at the call site_ than the original code was. Thanks, Marc -- Marc Mutz <marc.m...@kdab.com> | Senior Software Engineer KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company Tel: +49-30-521325470 KDAB - Qt, C++ and OpenGL Experts _______________________________________________ Development mailing list Development@qt-project.org http://lists.qt-project.org/mailman/listinfo/development