I don't think it is so much a matter of short routines mattering more in OO
as it is that short routines make more sense and are more natural. If am
procedural coding and following a rule of thumb that each routine should do
one thing (and do it well), and if a particular one-thing is even
moderately complex then I can easily wind up with 20 line, 40 line, or even 100 line
routines. Iff that code is tightly integrated and really involved in doing
just one thing, then even the 100 line routine flows naturally.
Some people might find several seemingly logical chunks of that 100 line
routine and pull them into their own routines giving say a 30 line routine
with half a dozen 10-20 line helper routines. This is usually false
complexity reduction. The code is highly integrated, and all we've done
is push the complexity around a smattering of highly coupled routines,
rather than leaving it in a single logical flow (we've probably raised
the overall complexity in our attempt to reduce local complexity). It is
*often* (not always) a mistake to take a nice integrated 100 line routine
and break it into 10 coupled routines (the double meaning of 'break' is
In the OO world we live with highly coupled code all the time. But in OO it
is an organized coupling that guides the design from the beginning, leading
to a multitude of short methods in a class that rely on each other as well
as state. It is not simply a way of collecting and grouping coupled code,
modules (or packages, or libraries, etc) can do that, it is a way of
structuring and organizing the coupling in a manner that relieves the
programmer of having to manage it. Thus, not only are short methods more
natural, very long methods are *often* (not always) indicative of something
amiss in the design.
But all this is but one viewpoint, and simplified for expedience.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||