Scott / wrox community -
I had a question about your thoughts on extracting web.config settings (i.e. connection strings, etc) in a layer other than the UI, like even as far down as the repository in a layered application.
In the Chapter4 Domain Model code example we have the following line in the repository:
Code:
_connectionString = ConfigurationManager.ConnectionStrings["BankAccountConnectionString"].ConnectionString;
I have always been weary of extrapolating settings from the web.config several layers down in an application. To me it feels like the lower layers expecting this data then creates a tightly-coupled feel to a specific configuration 4-5 layers up in the UI.
The wonderful effect of having the application in layers like described in your book, is how easy it would be to make the layers portable or even switch out UI technologies because the apps are so well designed into layers of responsibility. With this direct reference to a .config 4 layers up, the repository couldn't move to another UI technology since it is dependent on the web.config connection settings (without making sure the .config settings in the new technology were identical).
The alternative is to have these settings extracted at the topmost level (UI), and then passed down the layers, allowing the layers to be independent of a .config in another layer. Making each layer essentially free of dependencies from other layers, including configuration data.
What is your feeling on this topic? I know this book is ASP.NET centric and maybe the cause for assuming all UI layers will have the web.config present, but the ideas are so good and can be applied beyond ASP.NET. Have you used any other approach from mitigating these settings values down through the layers? I could be way off to on this too and calling the .config several layers up is accepted practice, and if so I am good with that too. Just wanted to see your thoughts.
This book is fantastic, A++++++++. Will be giving some 5 star reviews on it once I finish the book. Terrific work Scott!
