Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

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?

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2021-05-16 10:21 GMT
Find Nodes?
    Voting Booth?
    Perl 7 will be out ...

    Results (151 votes). Check out past polls.