Hi again, please ignore the obvious errors such as 'undefined', I am at the very early stages of porting.

Reasoning

'igaro' doesn't really need OO porting as per say, the only reason I'm doing it is to make the code less fragile. I think.

Another reason is my relative lack of OO experience, and I have a tech interview on Tuesday. I'm bringing myself up to speed the hard way. :)

The code

In essence I'd coded so that one function = one file. It was rare for this to be anything different, which of course diminished the need for employing classes.

Now I'm converting the common functions, but the logic seems a little daft. Before I'd require the file and stick it into the namespace as 'igaro_xxx_xxx'. Now I'm instantiating the function into $self->{common}{xxx_xxx} and the other functions that used to call &igaro_xxx_xxx will have to do $self->{common}{xxx_xxx}->exec();

I have worked around the sharing of parent data by sending a reference to the parent through the params, like $self->{common}{xxx_xxx}->exec(parent=>$self);

Previously all the data was stored in several global hashes like %DATA.

My brain has just about fried itself.


In reply to Re^2: OO Conversion Query - Sharing Data by snoopy20
in thread OO Conversion Query - Sharing Data by snoopy20

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.