(e-mail address removed) writes:
I find that odd.
I'm surprised you find it odd...
If anything, I find it easier to write /large/
functions which do a single thing.
that *I* find odd
Individual components of it tend to
be more tangled up with each other.
if it's got "components" I'd argue it was too big
It's as if there's an optimum granularity (which varies
according to exactly what it is I'm actually doing)
with you up to here!
below which either (a) describing the function's purpose and
effects becomes too difficult or
I usually find it easier to describe what a small function
does. Large functions tend to require some sort of
compound sentence to describe them.
(b) you don't actually save anything by calling it.
if you mean time or memory, then no. But there are
other reasons write functions...
As a firm believer in `once and only once' (from before I heard that
slogan attached to it),
me too
I'll strip stuff out into a separate function if
I need it in two places[1].
I thought the idea that this was the only reason to
encapsulate a piece of code in a function died out
in about 1956
Apart from that, a piece of functionality
has to lift out very cleanly for me to think it's worth separating.
if it can't be lifted out cleanly then maybe the whole
function needs redesigning.
Ok my code isn't composed entirely of cohesive, loosly coupled,
small functions; each of which Does One Thing Well and can
be described with a short, pithy phrase (most likely embedded
in the function's name). But I can dream.
[1] This pursuit also leads me into macrology that leaves some others
queasy. :-(
ug. macros the 8th plague.
--
Nick Keighley
Programming should never be boring, because anything
mundane and repetitive should be done by the computer.
~Alan Turing
"The best software is simple, elegant, and full of drama"
- Grady Booch
"Programs must be written for people to read, and only
incidentally for machines to execute."
- Abelson & Sussman, Structure and Interpretation of Computer Programs