79 chars or more?
Stefan Schwarzer
sschwarzer at sschwarzer.net
Tue Aug 17 15:32:14 EDT 2010
Hi Andrei,
On 2010-08-17 18:43, AK wrote:
> But let me ask you, would you really prefer to have:
>
>>>> self.expiration_date = translate_date(
>>>> find(response, 'MPNExpirationDate').text,
>>>> '%Y-%m-%d', '%m%d%Y')
>
> (or the 4-line version of this above), even when it necessitates
> creation of a new function, rather than have this code on two lines?
Given that the reformatted code is three lines and the
former code two lines, I probably wouldn't change anything
but the formatting as shown. :)
> After all, I think it's a matter of balance between readability,
> expressiveness and succinctness. If I split a function in two, that
> still means that understanding the functionality of the code will
> require scrolling around and looking at the second function. I guess
> what I'm trying to say that we shouldn't just care about readability of
> lines but also readability of functions and blocks of functionality
> (that may include several functions that accomplish a single "task".)
I think you're right here; you should keep the overall
readability or (maintainability on the whole) in mind.
I agree with Neil that good refactoring can _improve_ the
understandability of the code, and it won't necessarily
require you to look up the code of the extracted
function or method.
Stefan
More information about the Python-list
mailing list