On 5/3/11 5:46 PM, MRAB wrote:
On 03/05/2011 23:31, Chris Angelico wrote:
On Wed, May 4, 2011 at 8:08 AM, Jabba Laci<jabba.l...@gmail.com> wrote:
Hi,
I'm just reading Robert M. Martin's book entitled "Clean Code". In Ch.
5 he says that a function that is called should be below a function
that does the calling. This creates a nice flow down from top to
bottom.
I prefer to define my terms before I use them. Classes, functions, etc
get defined at the top and called down below. It's a stylistic thing,
but it ties in with what you would do in a debate or scholarly
document; and if you're skimming such a document and you don't
understand a term, you know to scan upwards for its definition.
It's just a stylistic thing, you can do it whichever way you think best!
You also need to remember that in Python, function and class
definitions are _not_ declarations, but statements which have the
effect of adding a name to the namespace.
If you try to call a function before the flow of control has seen the
function definition, you'll get a NameError.
That's not really the issue at hand. The advice is about how to order the
definition of functions that call each other, not interspersing function calls
at the top level.
I'm willing to bet that there is no solid empirical evidence that one ordering
would be preferred to another. I am further willing to bet that should any such
study be done, the average effect would be much smaller than personal variation
(while it may be statistically significant, it won't be clinically significant).
My third bet would be that picking any consistent style would have a larger
effect over a random arrangement than either one consistent style over the
other, and that this effect would be significant in both the statistical and
clinical senses.
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
--
http://mail.python.org/mailman/listinfo/python-list