Scott Hanselman

The Weekly Source Code 1

August 16, 2007 Comment on this post [4] Posted in Programming | Source Code
Sponsored By

In my new ongoing quest to read source code to be a better developer, I now present the first in an infinite number of a weekly series called "The Weekly Source Code." Here's some source I'm reading this week that I enjoyed.

Feel free to send me links to cool source that you find hasn't been given a good read.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service
August 17, 2007 9:24
It would be cool if someone created an RSS feed containing byte-sized snippets of beautiful code.

Anyway, here's my contribution:

RSS feed of the Firebug source code:
http://feedchopper.ning.com/index.php/main/feed/showUrl?id=3299679

RSS feed of the Haskell Prelude:
http://feedchopper.ning.com/index.php/main/feed/showUrl?id=6633928
August 22, 2007 2:35
The Duck Typing project is pretty interesting, but doesn't have much to do with the Var type of situation. What he's doing is a very clever bit of reflection.

He's dynamically creating a type at runtime that wraps the original type using reflection. It basically dynamically creates a proxy to the target type. So, for example, you could DuckType a control of type DropDownList as a control of type RadioButtonList as long as you access properties that are of the same type. So, you could do something like the following:

RadioButtonList rblDuck = DuckTyping.Cast<RadioButtonList>(myDropDownList);
rbl.SelectedValue = "Example";

Both RadioButtonLists and DropDownLists have "SelectedValue" in common, so the RadioButtonList "ducktype" acts as a proxy to the actual underlying DropDownList, forwarding the values on to myDropDownList. Neat stuff.

This is all at runtime, though. Var is different because it is a type that is determined at compile time. It's possible that Microsoft's DLR strategy is similar, but I'm not sure about that yet.
September 19, 2007 16:34
test bugaga
September 19, 2007 17:35
test bugaga

Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.