|more useful options|
OO style question: how much information to hide?by Ovid (Cardinal)
|on Jun 11, 2003 at 00:21 UTC||Need Help??|
Ovid has asked for the wisdom of the Perl Monks concerning the following question:
A little OO style question has been bugging me for a while. Consider HTML::TokeParser::Simple. Currently, if you want to alter attributes of start tags, you can do this:
Some appear to argue that the "is_start_tag" test is superfluous. Basically, mvc argued that having the test is irrelevent. If the object can do what I want, let it do it, otherwise it ignores the message. So how does that work out if I want to clean up all references to font tags in a HTML document?
Right now to do that, I have to do the following:
Currently, calling set_attr() or del_attr() on anything but a start tag will croak(). (That was a mistake that I will fix. It should carp and move on.) Other than that, how do you feel about the two styles above? My concern with the former style is the possibility a bug in the code leading someone to accidentally try to set attributes on something other than start tags and missing the start tags themselves. In other words, if the code doesn't alert you to the appropriateness of the message, how do you know if the right objects are getting the right messages?
My concern with the latter stems from adding extra tests in the code. The more code, the more bugs. Which style would you choose and why?