Nov 13, 2008

Double Dispatch Principle or the "Shit Hits the Fun"

The other day I was thinking about Double Dispatch Principle and it's benefits and came up with the following code sample:

public class Air
{
}

public class Fun
{
public void Run(Air air)
{ }
}

public class Sheet : Air
{
public void Hit(Fun theFun)
{
theFun.Run(this);
}
}

public class Program
{
public void Process()
{
var theFun = new Fun();
new Sheet().Hit(theFun);
}
}

1 comment:

Anonymous said...

change to "shit hits the fan"