Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

As I pointed out in another node in this node tree, you seem to be looking for:

use Scalar::Util qw(reftype); sub new { my($class, $args) = @_; return unless $args; return unless reftype($args) eq 'HASH'; # ...

Also, it looks as if you are trying to blur the line between Perl object interfaces and Perl blessed reference method interfaces. Since the two are fully independent (any Perl blessed reference can be implemented using a reference to any Perl object), I suggest you are asking the wrong question... :-)

To expand upon my "any Perl blessed reference can be implemented using a reference to any Perl object" - the initial version of my class could use a HASH to store member fields, while a later version uses an ARRAY to improve on efficiency, and reduce storage requirements. In pure OO philosophy, your code should not rely on how my class stores its member fields. If your code is expecting to get a hash reference as an argument, it is my responsibility as the caller to pass you a hash reference. If my hash reference happens to be blessed, it shouldn't matter. You should use reftype() and not care about the blessed'ness of the structure. It is unfortunate that Scalar::Util was not included in earlier versions of Perl.


In reply to Re: Re: Re: Class::Interface -- isa() Considered Harmful by MarkM
in thread Class::Interface -- isa() Considered Harmful by chromatic

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 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?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-03-29 09:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found