From: Dave Thomas Date: 2002-02-04T22:48:01+09:00 Subject: Re: Subclassing vs Subtyping (partly OOP vs FP) Robert Feldt writes: > However, I found it relevant since it made me think about why this > would not happen in Ruby. My conclusion was not so much that this is > a question of Ruby or not but about whether I think enough about the > contracts involved. Also that it could be a good thing to make the > implicit protocols more explicit (by more "formal" unit tests?). Robert: That's a good point. How would you go about documenting protocols using unit tests? Could it be a function of mixin: by including a particular mixin, you're adding a protocol to your class. Could the mixin contain tests to check that the classes it is mixed in to are up the the task? Say BagCollectable was a module defining a set of helper methods for bag, and it relied on the classes that used it implementing #add, #remove, #contains?, and #each. At the very least, as it was included into a class, it could check that these methods exist. But how could we go further? How could it perform some kind of semantic check of these methods? If we could pull that off, we'd have something interesting. Dave