Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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 intentional).

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.


In reply to Re: Short routines matter more in OO? by Anonymous Monk
in thread Short routines matter more in OO? by tilly

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2024-04-23 15:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found