On Fri, Jul 01, 2005 at 10:28:29AM -0700, Ovid wrote:
> So, just for the sake of argument, imagine I write a class where I
> periodically returns array refs to the user.  I do this by building
> them every time they're called.  Later, I realize that my methods are
> deterministic so I start caching results and returning them instead of
> rebuilding the array each time.  I'm expecting my test suite to still
> continue working but under this proposed idea, it could be a nightmare
> for me to debug.  Heck, when I print out the arrays with Data::Dumper,
> I'll see the same values and be mystified why they're not equivalent.

Another nail driven home.

Ovid's given an example of how this violates encapsulation making it 
difficult to write black box tests which do not make assumptions about the
implementation.  Under Yves' suggestion if you replace a set of identical 
objects with a singleton your tests fail.  This is wrong since the external
interface did not change.  This is consistent with is_deeply()'s positions
on overloading, tying and blessing.

"wrong" is relative because where I'm drawing the black box is a choice.
Yves would have it be a bit deeper so the change from copied object to
singleton becomes apparent.  And maybe you do want that, if the objects
are alterable then there could be an interface change as now altering
one alters the other... or maybe it doesn't.  Maybe its COW.

Point is the line between "internal" and "external" expectations has to be
drawn somewhere.  I've drawn it a bit further out from true equivalency
to ignore some differences which are usually inconsequential.  Yves would 
like it pushed back to test true equivalency.  The two positions cannot 
co-exist in the same function.  One is not right nor wrong, they're just
different functions.


-- 
Michael G Schwern     [EMAIL PROTECTED]     http://www.pobox.com/~schwern
Just call me 'Moron Sugar'.
        http://www.somethingpositive.net/sp05182002.shtml

Reply via email to