On Thu, Nov 4, 2010 at 11:09 AM, Mark Wooding <m...@distorted.org.uk> wrote: > Chris Rebert <c...@rebertia.com> writes: >> Or, if possible, refactor the conditional into a function (call) so >> it's no longer multiline in the first place. > > No! This /increases/ cognitive load for readers, because they have to > deal with the indirection through the name.
If it's well-named, then the reader can delay having to read the definition. > If you actually use the > function multiple times, the mental overhead of forming the abstraction > and associating it with the function name is shared across the various > call sites and it's probably worth it. If it's only called once, leave > it inline. I'd say it's a judgment call. If the condition is sufficiently complicated and can be well-named, then I see justifying refactoring it into a function even if it's only used once. However, this is admittedly not a common situation. Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list