Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

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

by perrin (Chancellor)
on Jun 11, 2003 at 00:28 UTC ( #264921=note: print w/ replies, xml ) Need Help??


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

There are exceptions to the rule, but in general objects should not silently fail. If you call $dog->quack() and it can't quack, it should die loudly to let you know you have made a horrible mistake. Warnings are for things like "that method call was superfluous" not "I am unable to do what you asked."

UPDATE: I read the comments from mvc. He seems to have been simply saying that you should try for the highest possible abstraction of what you're trying to do. This is obviously good advice, but I don't think there was anything wrong with what you were doing in that example. This one is a harder call. In this case you're dealing with two instances of tokens with little reason to differentiate between them, and some start tags might not have any attributes either.

I think you should recast your thinking like this: tokens can have attributes, deleting an attribute on a token that doesn't actually have that attribute is not considered an error, therefore deleting an attribute on an end tag is not considered an error.


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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2014-11-26 01:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (160 votes), past polls