Parameters that cause or are caused by leaky abstractions

It's common to see a database connection string or URL passed into the business-logic layer for the sole purpose of passing it down to the data layer (the database or HTTP client). Typically, the motivation is to pass the config through the layers so that we can swap out the live config for something friendlier for testing. This sounds good, but it breaks the encapsulation of the data layer. Perhaps more concerning is that if we were to change the data-layer implementation to something else, we would likely have extensive shotgun surgery on our hands. The actual problem here is not the testing, but how we have chosen to swap out the data layer. Using the DIP, we could define our requirements as an interface in the business-logic layer and then mock or stub it. This would completely decouple the business-logic layer from the data layer and remove the need to pass the test configuration.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.36.231