From: David Masover Date: 2008-05-29T07:01:45+09:00 Subject: Re: The duck's backside On Wednesday 28 May 2008 16:25:15 John Carter wrote: > class MyObject > > def initialize( _a, _b, _c) > @a = _a.quacks_like( :qwaak, :waddle, :swim) > @b = _b.static_type_check String > @c = _c.polymorphic_type_check MyBaseClass > end > > # Without the checks above, the exceptions would be thrown here, with the buggyline nowhere on the backtrace! > def my_use > @a.qwaak( @b) + @c > end > end I'm fine with that, because 99% of the time, I'll never hit that exception. When I do, it's usually possible to deal with it -- in this case, you would find where @a is set, and add a check there. I think you're arguing to add that check first. I would call that premature strictness -- but if you have to do it, I like your way. Oh, also: Most of the time, I use setters/getters (attr_accessor), even when something's mostly going to be internal. That simplifies this process -- I know there was a problem with a, so I can override a's setter with something that performs the same check. But that's also probably overkill -- if a class can't fit on a page, it's probably too big and should be broken down.