Scott Hanselman

The Weekly Source Code 1

August 16, '07 Comments [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. I am a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by ORCS Web
Friday, August 17, 2007 5:24:19 AM UTC
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
Tuesday, August 21, 2007 10:35:04 PM UTC
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.
Wednesday, September 19, 2007 12:34:04 PM UTC
test bugaga
Wednesday, September 19, 2007 1:35:17 PM UTC
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.