Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

At Re^3: sorting a complex multidimensional hash, I took some gently stated critique seriously and tried to find a better way of expressing the ST and GRT versions of that sort. Then later, Ven'Tatsu's post made me look for a CPAN solution.

If you like the idea of encapsulating your ST sorts (or the GRTs & Orcish Manouvers), then there is an existing module that will do this for you Sort::Maker.

It's an impeccably pedigreed module; cleanly coded; well documented etc. The problem is, it took me much longer to work out how to write even a simple ST or GRT using it than writing them directly. The resultant code requires just as much typing and (IMO) is no clearer or easy to maintain that the usual map-sort-map version.

I then spent many hours trying to work out how to apply it to Re: sorting a complex multidimensional hash and got nowhere. I simply couldn't work out how to use it to this sort, either the ST or the GRT version. Both of my hand coded versions took under an hour each to write and test.

There is nothing wrong with the module, not it's interface design, nor it's documentation. The problem is that even for relatively simple versions of either style of sort, you have to pass all the information required to perform the pre- and post- processing of the data, plus the comparator, plus the direction of the required sort into the module as small, discrete chunks of code.

I find it's just much easier to see what is going on, and what is going wrong, and to test and spot where they are going wrong, when I write that code in the usual manner, than I do as lots of discrete little bits.

I have similar misgiving with callback interfaces typified by things like the various HTML parsing modules. You're constantly operating one level removed from the place of execution. If what you code works first time, they're great. It's when I get a problem, make a mistake, that I find myself having to bypass the documentation and going to the source to try and work out what and where the problem lies. At that point, the main benefits of using a canned solution tend to go out of the window.

Even if I succeed in making the combination work, if the code needs modification at some later stage, I (or the whomever has to maintain the code), has the same problem of trying to understand the combined effect of two separate pices of code, rather than one.

I am the only one that feels this way?

How would you simplify/clarify the coding of ST?


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
"Memory, processor, disk in that order on the hardware side. Algorithm, algoritm, algorithm on the code side." - tachyon

In reply to To use a module...or not. by BrowserUk

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 meditating upon the Monastery: (3)
As of 2024-04-25 07:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found