If you we're about to start a new project with some third party libraries (logging, orm, di, whatever), would you prefer to configure all this libraries via programming with fluent interfaces or with XML files?
Would you use a library that only supports one of these options (Fluent or XML)? Or do you prefer libraries that gives you the possibility to choose between a variety of configuration strategies.
For those who like code, take this as a hypothetical example (written in C#).
This is Fluent Configuration:
LogConfiguration.ConfigureStorage()
.ForDatabase("CommonDB")
.AsMsSqlDatabase()
.WithConnectionString("server=(local); database=Northwind; Integrated Security=true;")
.AsDefault();
This is XML Configuration:
<logging>
<database name="CommonDB" provider="MSSQL" connString="server=(local); database=Northwind; Integrated Security=true;" default="true" />
</logging>
Finally, what are the Pros and Cons of Fluent and XML Configuration?
Until now, we've come to this:
Fluent Configuration in Code
Pros
Cons
XML Configuration
Pros
Cons
I tend to use xml for attributes I might want to change post-build (such as connection strings, loggers)
I prefer strongly typed (compiled) fluent configuration in code for things such as NHibernate mappings that only change during development.