Today at work we had a lunch presentation by the ever-enlightened Jeremy Larkin. His topic of choice - Ruby.
Perhaps one of the coolest things that I gleamed from the conversation was the concept of dynamic typing in Ruby. Granted, I have worked with the basic concepts of dynamic typing in other languages before, but they typically only had limited support. Ruby is dynamically typed from the ground up.
Dynamic typing largely renders irrelevant the whole concept of an interface as a solution for polymorphically accessing objects that do not inherit directly from the same inheritence chain. Instead, methods are validated at runtime during invocation. Therefore, if you want to access a certain method on an object polymorphically, the instance needs only to implement the method being invoked with the proper method signature at the exact moment that a call is made on the method.
To go off topic for a minute, I recently read an article somewhere that made the case that interfaces make lousy service contracts. According to the article, a service contract would be more appropriately defined by some number of unit tests. A class would not be a valid implementation of an interface by method signatures alone. Rather, the class must be able to pass the tests required by the interface.
This got me thinking and I haven't figured it out yet. Somehow, when an interface is implemented, the associated unit tests for the interface should run against the code implementing the interface. If the code validates, it represents a valid implementation of the interface. This may be possible in Ruby where even things like inheritance may fire events that can be handled. That would be the easiest way.
In something like C#, I figured that the best place to attempt to handle this situation would be through a dependency injection engine. For instance, the first time a request is made on the DI engine for an instance of the interface, whatever type is mapped to the interface would be tested. The DI engine would throw if the type being instantiated failed the interface tests.
These are just thoughts at the moment; I have no implementation yet.