Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Ok, lots of good advice here however there is an important factor thus far not really covered.

I use subs to simplify complex code. I dont mean in the obvious manor where subs can offer logical partitioning but more on the conceptual level. I am a man with a small brain (damn but if pooh does not have a comment for all eventuallities) When dealing with a particularly thorny programming challenge I avoid mapping the problem into the language space as is often done, instead I map the language into the problem space. Consider the nature of the problem you are solving deduce the language of the problem. Code subs to allow you to talk that language; addVector, splitStringByChar. Many of these subs could often contain a single line of code. Then solve your problem using the language of those subs. This frees you from the petty detail of the underlying -programming- language. Once the problem is solved and working the depreciate redundant subs by moving the code from the sub into the main body of the code. This is an idea most often seen in OO programming and it is very powerful (most good programmers do it without meaning too), it is appropriate for application and algorithmic centric problems.

jplindstrom touched on this idea in his node in this thread, I agree COMPLETELY with what he said it is dangerous to fractionalise code into many small and useless subs. It is important to rationalise the need for each sub at the end and deprecate where required.
--

Zigster


In reply to (Zigster) Map the language into the problem space by zigster
in thread To sub or not to sub, that is the question? by tachyon

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 chanting in the Monastery: (9)
As of 2024-03-28 14:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found