using functions and file renaming problem

Peter Hansen peter at engcorp.com
Sat Jul 19 10:14:44 EDT 2003


hokiegal99 wrote:
> 
> My scripts aren't long and complex, so I don't really *need* to use
> functions. But the idea of using them is appealing to me because it
> seems the right thing to do from a design point of view. I can see how
> larger, more complex programs would get out of hand if the programmer
> did not use functions so they'd be absolutely necessary there. But if
> they allow larger programs to have a better overall design that's more
> compact and readable (like your examples showed) then one could argue
> that they would do the same for smaller, simplier programs too.

Uh oh!  You're being poisoned with the meme of "right design".

Don't use functions because they "seem the right thing to do", use
them because *they reduce repetition*, or simplify code by *making
it more readable*.

If you aren't reducing repetition with them you are losing the
primary benefit.  If you also aren't making your code more readable,
don't use functions.

Whatever you do, don't use them just because somebody has convinced
you "they're the right thing".

-Peter




More information about the Python-list mailing list