Some good info in the previous post from jimt. I too have been asking some of the same questions.

The big issue to deal with is that their are just SO many ways to create and manage objects in Perl. My rather limited investigation finds that blessed hashes behave somewhat like ordinary hashes - have all the same autovivification behaviour.

What I did was to write a simple piece of code that watched memory usage as I instantiated the same class a number of times. As expected the memory usage is directly related to the hash size involved and has basically nothing to do with the code. Although, as pointed out before, this need not always be the case, it's up to you. Hashes with dissimilar numbers of keys seem to populate with different memory usage.

When I did the same for the class re-written as an 'inside-out' (per TheDamian in Perl Best Practices) the memory usage was a little higher for each instance and the benchmark times were a little higher, but not so much as to be prohibitive. I won't publish them because I am still very much a neophyte at the OOP game and I am sure that my methodology is quite likely flawed.

That being said, it is a journey that needs to be made so that I understand this stuff better. My guides have been "Object Oriented Perl" by TheDamian as well as his "Perl Best Practices". "Higher Order Perl" by Dominus has some material, as does Chapter 5 of "Perl Hacks" by TheDamian, chromatic and Ovid. There is also a lot here in the Monastery, especially in postings by AbigailII.

Happy hunting, jdtoronto


In reply to Re: Perl Objects, Internal Representation -- How?? by jdtoronto
in thread Perl Objects, Internal Representation -- How?? by bratwiz

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.