Quack quack

by benl

Mark mentions duck typing as a neat way of handling the object-as-XML coupling scenario. Of course, us Ruby hackers are already familiar with duck typing (if I can lump myself in with that bunch yet:) ) as are users of other dynamic languages.

The shortest and most simplistic explanation of duck typing I’ve seen is:

an object having all the methods described in an interface can be made to implement that interface dynamically at runtime, even if the object’s type does not include the interface in its definition

So why the term: “duck type”:

If it walks like a duck and quacks like a duck, it must be a duck!

There are duck type frameworks available for .NET, NDuck being one of the more popular.

Advertisements