Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: OO style question: how much information to hide?

by ViceRaid (Chaplain)
on Jun 11, 2003 at 10:01 UTC ( #264995=note: print w/ replies, xml ) Need Help??


in reply to OO style question: how much information to hide?

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


Comment on Re: OO style question: how much information to hide?
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://264995]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2014-09-15 03:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (145 votes), past polls