Most software projects I’ve worked on had at least one feature that needed to be dynamic, where certain aspects of the program wouldn’t be known until runtime. Sometimes, those aspects would be known as the application was running on the developer’s machine (data binding in WPF, for instance, is late bound), and other times, they’d only be known at the end-user’s machine (maybe based on the user’s selections, maybe based on the environment).
Before landing in the strongly-typed world of C#, I used to write software in FoxPro, which was a dynamic language. We used to store large blocks of code on tables in the database, and execute that code during run time after all the required pieces of the puzzle were known. That was not something easy to do in the early days of C#.
There are a number of ways to either add or change behavior of an application during runtime, and granted, doing things in C# exactly the same way we did in FoxPro was NOT the way to go! However, when dynamic features where introduced back in C# 4.0, I was glad to have it in my toolbox, and I believe I’ve found good use for it in several situations.
For this post, my main point is just that I think using the dynamic features in C# is fun. I’ll be writing up more posts to talk about some basic stuff around these features, and also giving some examples on how I’ve used it.