One type of the all-time hot question being asked here is about hash of hashes, hash of hashes of hases, array of hashes ... Questions come from different aspects of those complex data structures, which create lots of confusion among new comers of the Perl world (when I was new to Perl, I was confused too).

For a Perl programmer with reasonable amount of experience, those questions are usually easy to answer, and the immediate problem always got resolved. However one big problem behind all this, is rarely touched.

99% of the time, the fact that multi-tier collections of collections being exposed to a single module, points to poor modulization of code, or lack of OO design. If the code happens to have a OO face, then it indicates lack of genuine understanding of OO. As a matter of fact, 99% of the time, OO classes should only see one level of collection. The elements of the collection, whatever how complex they are, their internal structure should not be exposed to the class that holds the collection. Rememebr that, this principle is not only for one tier (or the top tier), it applies to all tiers. In OO world, you do not have collections of complex child data strctures, but only have collections of simple objects (whatever how complex they are indeed, that fact is not exposed, and the class that contains them should never care that complexity).

Your data might be really complex, but it is all about perception and focus.

There is absolutely no reason for a person to believe that his/her data is complex enough and cannot be clearly contained in layers. Think about it, if we are dealing with data that connot be contained as single-tier collection of objects, from day to day, then RDBMS has been dead now for a long time already.

Naked complex data structure can easily create maintainance nightmares. If you don't want it, don't creat it for others.

There will be times you make exceptions, but remember that 99% of the time, the door should be closed.


In reply to multi-tier collections & lack of modulization/OO by pg

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.