I’ve just started using Inversion of Control containers and I’m having a difficult time understanding when to use the fluent API or XML when configuring and registering components.
Are there any best practices around when you should prefer one over the other? Or is this simply developer preference? Would it be considered bad practice to mix them in a simple application?
Thanks!
The sweet spot for me is a combination of the two. XML for pulling together large units of functionality and possibly configuring them at deployment time; fluent for setting up the individual components within those units. See http://code.google.com/p/autofac/wiki/StructuringWithModules for an Autofac example. Other containers often have similar capabilities.