Actually, I write my own tree and graph modules to suit the task ... I'm a control freak. That, and I don't usually like tweaking other people's modules when they don't do exacty what I want (style issues) and datastructures are important enough that you should understand how all of them in your program are implemented. Too many people these days learn programming by way of languages where all of the datastructure work is done for them, so they really just become users of tools instead of people that can think for themselves...

Anyhow, on the topic of "what do I do", while nested hashes are ok for serialization, they are too unsafe due to the possiblity of coding errors (I prefer syntax errors to runtime errors), so I'll usually do something specialized and optomzied to the task. This probably involves having some objects behave as Nodes, which is where we need mixins (subclassing Node is wrong!) ... which is not really covered cleanly in Perl 5.x

I also abhor the design pattern FAD so I avoid things such as VisitorFactories, as I get this silly image of a factory with Tourists popping out of the loading dock -- that's not what OO is supposed to be about. I think you've got a Forrest::Complex there instead of a Tree::Simple. No reason to rant against Tree::DAG_Node about line count (line count wars are always petty) in your POD when you have a design such as this requiring so many modules for a "Tree::Simple" class.

(edited slightly to tone down design pattern rant)


In reply to Re: How do "you" make a tree in perl by SpanishInquisition
in thread How do "you" make a tree in perl by stvn

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.