I've used it to wrap classes that I wouldn't know anything about, but needed to provide add-on methods for component management. Using this technique, I don't have to care what someone wants to use as a component (as long as it's a class).

A snippet from IOC::Lite follows:

sub AUTOLOAD{ my($self, @args) = @_; my @method_and_structure = split m|\:\:|, $AUTOLOAD; my $method = $method_and_structure[@method_and_structure-1]; if ($self->{object}->can($method)){ return $self->{object}->$method(@args); } die ">$method is not found on " . $self->get_type() . "\n"; }

I've taken the concept a little further, almost AOP like, in the version of IOC::Lite I'm working on now. That way I can add all types of features to objects the container doesn't own. The basic component management methods will be first, followed closely by dynamic logging. Not sure where I'll head from there.

Sorry if this is just rambling. Bottom line: I think it would be quite useful on large software projects. I can't tell you how many times I wished I had this feature when coding in (C/C++/Java/etc)

Cheers,

John

janitored by ybiC: Replace frowned-upon <pre> tags with Monastery-standard <code> tags


In reply to Re: AUTOLOAD - the good, the bad, and the ugly by raptnor2
in thread AUTOLOAD - the good, the bad, and the ugly by shemp

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.