## Uncoupling Configuration Files

Tight coupling is a known source for inflexible and hard to test code. In this post I want to talk about a rather unexpected source of tight coupling - configuration files. Configuration files are external dependencies. As other external dependencies, its infrastructure may change in the future, and it should be easily mocked for unit testing. Modern software frameworks provide means for easy access to the values stored in configuration files. In the .NET framework configuration files can be accessed using the ConfigurationManager:

<?xml version="1.0"?>
<configuration>
<appSettings>

int foo = int.Parse(ConfigurationManager.AppSetttings[“Foo”]);