On Tue, 23 Feb 2016, at 03:31 PM, Peter Morris wrote:

> but having #save raise an exception breaks ducks. save doesn't raise 
> exceptions.

If it would be an error to call `#save` on a missing basket, your code won’t do 
it, so there’s no problem. If you make a mistake and your code does do it, you 
want to know about it, so you really want it to raise.

Can you elaborate on what “breaks ducks” means? I’m finding it hard to describe 
what I think you’re trying to say. As in, what’s the actual problem?

Are you saying that any object that quacks like a Duck must have the same API 
as Duck, even if you never call some of those methods on the duck-like object?

Here’s another way to think about it…

If I wrote `Basket` and `MissingBasket` from scratch (without inheritance, or 
ActiveRecord), and needed to call `#save` on both of them, I’d implement it on 
both of them (reusing code as/if appropriate).

If I only ever needed to call it on `Basket` I wouldn’t define it on 
`MissingBasket` as well, just because `Basket` needed a `#save` method.

-- 
You received this message because you are subscribed to the Google Groups 
"North West Ruby User Group (NWRUG)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send an email to [email protected].
Visit this group at https://groups.google.com/group/nwrug-members.
For more options, visit https://groups.google.com/d/optout.

Reply via email to