allowing braces around suites
iketo2 at netscape.net
Thu Sep 2 02:40:26 CEST 2004
>>>>> "Antoon" == Antoon Pardon <apardon at forel.vub.ac.be> writes:
Antoon> If you need a function or class just to avoid nesting,
Antoon> then IMO you have only camoeflaged it. In order to
Antoon> understand what is going on you still need to understand
Antoon> how the nesting of a number of controls prroduce a certain
Antoon> result and when you write a function just to avoid nesting
Antoon> it often enough makes readablity harder.
Splitting a deeply nested function in the wrong way can make a program
harder to understand. But that doesn't mean that in such case what
you should do is to leave it as is. It's the comparsion of something
bad with something that is just as bad. In either way that is bad:
the program is easy enough to understand only by the original writer,
and only at the instant when the code is written.
In nearly every single time this happen, this is because there is a
lack of a clean abstraction that allows part of the function to be
moved out of the main function. In the long run, the right answer is
nearly always to form an abstraction that would allow nesting to be
removed, in a way that once the abstraction is recited, the program
becomes more or less trivial even if you look at it 3 months later.
And the end result will involve adding functions and perhaps classes.
It might seems that one "adds functions and classes just to avoid
nesting", but in reality they are used to form an abstraction that
would allow the program to be understood more easily.
More information about the Python-list