Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

comment on

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

Thanks, I've enjoyed this thread, and also my first taste of HTML::TokeParser::Simple's interface.

As a more general OO problem or pattern, I'd perhaps be interested in looking at the class which supplies the iterator method (H::TP::S), rather than the class of the objects over which it iterates (H::TP::S::Token). When I'm using a method that'll return some or all members of a larger collection, I'd like that method to guarantee what sort of objects will be returned. That way, I can safely call methods on the individual objects returned by the iterator which not all objects in the whole collection would have:

package HTML::TokeParser::Simple; sub get_start_token { my $self = shift; my $token; do { $token = $self->get_token; } until ( ! $token || $token->is_start_tag ); return $token; }

That said, this isn't that practically useful for a stream of objects, as in HTML::TP, where you want to act once and immediately and finally on every iterated object, rather than modifying a collection, then using a different iterator to do something else. The existing interface works like a treat.

ViceRaid


In reply to Re: OO style question: how much information to hide? by ViceRaid
in thread OO style question: how much information to hide? by Ovid

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 goofing around in the Monastery: (6)
As of 2024-04-23 15:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found