Configuring applications in code seems like a good idea. Configuring them in code written in a dynamic language seems even better. Let’s look at a simple example with IronPython.
I’ve kept this example as simple as possible to show the principles. The advantages of using Python code (it would be simple to use IronRuby, too) are that it’s simpler to write, testable, more powerful and doesn’t need pre-compiling. And it could do much more than set a couple of properties. In C# 4.0 the dynamic keyword would allow the Configuration class (and classes like it) to be dynamic, so that the properties and methods could be referenced at runtime without having to be declared ahead of time.
Recently I posted a short article about how to do simple configuration with IronPython. I figured that it would be easier with .NET 4.0 thanks to the dynamic support. And it is. Using Visual Studio 2010, create a new Console Application.
The result is (I think) more simple and elegant than the configuration code to which I’ve become accustomed.