From: "Florian Groß" Date: 2005-12-07T23:18:15+09:00 Subject: Re: Interfaces in Ruby? Jeff Cohen wrote: > One thing I'm trying to wrap my brain around is the lack of explicit > interface definitions. In C# we use interfaces so that client code can > program against an abstract interface, and then you can give that client > any concrete implementation of that interface as needed. Interfaces > provide a level of abstraction/indirection that increase reusability and > testability. As others have already noted in Ruby we generally do the simplest thing that will work -- which is just calling methods in most cases. Where that doesn't work we can still check for the presence of an included Module or methods. Or actually rescue the NoMethodError ourselves and try something else. There's a lot of ways. Anyway -- the reason for why I'm really posting is that I have played around with using unit tests for doing interfaces / contracts in Ruby. This can provide you with argument checking and similar things, but it is a toy. You can find this at http://ruby-contract.rubyforge.org/ It might also give you a general idea of how much power you can get out of Ruby's dynamic nature.