79 chars or more?
andrei.avk at gmail.com
Tue Aug 17 21:54:23 CEST 2010
On 08/17/2010 03:32 PM, Stefan Schwarzer wrote:
> 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.
I can certainly agree with that - although this sort of refactoring
(when I do it) is driven by the logic of the code rather than the need
to spread a long line over several lines :-). -andrei
More information about the Python-list