Search code examples
c#configurationapp-configdecouplingloose-coupling

Coupling with ConfigurationManager or passing parameters from one to another


Is it OK to get parameters for different level of system directly from configuration?

I mean specifically coupling every layer with ConfigurationManager in .Net instead of passing parameters by the creator through a constructor or somehow else.


Solution

  • In case you need unit tests configuration should be injected. http://www.devtrends.co.uk/blog/configuration-settings-are-a-dependency-that-should-be-injected

    And to make users of your class provide all of the parameters in deterministic manner (not guessing just relying on documentation, source code and exceptions). http://www.codeproject.com/Articles/196563/Don-t-use-ConfigurationManager