[Development] when to Extract Method (was Re: commas in ctor-init-lists)
edward.welbourne at qt.io
Fri Jun 3 15:14:13 CEST 2016
> The three clauses should stay three clauses if the action (their
> then-block) is independent. If the then-block, as you seem to suggest,
> is idenitical in tokens and semantics, then you *will* find a name to
> describe it that doesn't just transliterate the original C++ code into
> English: shouldDeleteThing, thingIsExpired, isNoLongerNeeded(thing),
Just to be clear, my example code's delete thing was just using that as
"there's some random tidy-up we need to do before any early return"; so
the three conditions are all "we need to return early from this method"
and the need to delete thing (which was nowhere referenced in any of the
conditionals) is incidental to the test. In such a case I very much
doubt there's a nice name for the method.
More information about the Development