On 10/3/07, Peter Verswyvelen <[EMAIL PROTECTED]> wrote: > I needed to type at least 3 times the amount of code, much > of which was boilerplate code, and the code is not elegant.
Reflection is your friend here. Example. Code before reflection: MyConfig { // some properties here public MyConfig() { XmlDocument dom = XmlHelper.Loadxml("config.xml"); somevalue1 = getIntValue( dom, "value1"); somevalue2 = getStringValue( dom, "value2"); // blah, blah, blah... } } With reflection: MyConfig { // some properties here public MyConfig() { ReflectionHelper.LoadMe( this, "config.xml" ); } } Just typed this in off the top of my head, so it might have errors in, but you get the idea. Of course, in this case you could just use Microsoft XmlSerializer, but I quite like the flexibility of using my own serializer (it's not that hard to write, just a hundred lines or so). ... but then, you can do something similar to display arbitrary objects to html... or write to sql... or write to a proprietary protocol... or ... many things! I kindof know what you mean though. Declaring variable types is kindof a pain, and of course anything to do with lists is insanely easier to write in Haskell (/Erlang). _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe