Multimethods in .Net

July 23, 2009


Today i was browsing through the wikipedia, and explored various programming concepts that i am still not even heared of.

One of those is multimethods, or multiple dispatch. Multiethod is a method, which is invoked dynamically based on it’s arguments. AFAIK, what I mostly use is inheritance, which forces to dynamically select the required method at runtime based on the object type. However, arguments are not involved in this process, they are checked at compile time.

Multimethods are also compared to a Visitor pattern. While this pattern achives the same result, it carries it’s own dissadvantages. Here is a nice explanation of Visitor vs MultiMethods

What is most interesting, is that .Net does not support these out of the box, but there is a library which does just that. Take a look at MultiMethods.Net

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: