I agree completely. I was responding to your suggestion that once objects are available, nested hashes are no longer useful.

I have had the misfortune of working on systems many times where internalized data management with limited scope was implemented using objects because everything must be an object. The resulting mess was much harder to maintain than any temporary structure would have been.

I've also been bitten by extremely complex protocols developed for the sole purpose of passing around objects that needed to be compatible across languages or versions. A simple list of hashes or hash of hashes might have been a better choice.

I'm not suggesting that hashes are better than object, they are just another tool we have available. The key is to understand the trade-offs. While I have certainly been in the situation you describe, I've also done time in other environments.

Objects don't necessarily solve the naming problem completely. What do you do with an interface that contains the methods find_object, get_object, make_object, create_object, and find_and_create_object (example anonymized from real code). At best, objects can reduce spelling errors by making them compile errors. But, making a badly-designed hash into a badly-designed object isn't really an improvement.

Until I tried to explain this, I hadn't really thought of using hashes on simple problems to help teach object design. It's sometimes easier to focus when the rest of the mechanics isn't in a student's way.

G. Wade

In reply to Re^4: Best Multidimensional Hash Practices? by gwadej
in thread Best Multidimensional Hash Practices? by DamianKaelGreen

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



  • 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:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.