Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Actually I do have an empty DESTROY but I did not bother copying it. In my case if there is no DESTROY then the program tries to do stuff on a non-existent CGI::Application reference.

The inheritence question is more interesting. Yes I can see my approach makes no special effort to handle inheritence. But actually I think it would work. Let me put my approach in words.

  1. Avoid AUTOLOAD except where it gives a big gain in loose coupling.
  2. Don't rely on someone else's module. The area is too complicated.
  3. This means you have to craft your own solution, but it is fairly simple.
  4. Define a DESTROY method as bad stuff happens otherwise.
  5. Define a semantically correct "can" function that either returns undef or a CODE ref.
  6. Define the AUTOLOAD function in the fairly standard way based upon the "can" function.
  7. If I were to write a derived class I would either inherit both "can" and "AUTOLOAD" and override less impactful functions; or I would override "can" in the same way and make use of SUPER::can where appropriate.
  8. I avoid multiple inheritence so I would make autoloading in a multiple inheritence scenario an absolute no.

In reply to Re^5: A working strategy to handle AUTOLOAD, can(), and (multiple) inheritance without touching UNIVERSAL? by SilasTheMonk
in thread A working strategy to handle AUTOLOAD, can(), and (multiple) inheritance without touching UNIVERSAL? by lodin

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (1)
As of 2021-10-22 01:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (85 votes). Check out past polls.

    Notices?