Chris Roberts, a Senior Architect in Credera’s Microsoft Solutions Practice, will be presenting on how to apply dependency injection to eliminate hidden dependencies. This is Chris’s 6th year to attend St. Louis of .NET and his 2nd year to present. Chris shares below the inspiration behind his topic:
“I have spent my entire career in technology consulting. Throughout that time, I have met a lot of amazing people. One of the most common challenges those people bring to the table to discuss with me is difficult to test code. There are many potential causes for teams to find their source code difficult to test, and I have made it my mission to help my clients understand what things are really preventing them from taking the next step along the road to quality enablement.
Perhaps the most common problems I run into when analyzing difficult to test code are hidden dependencies. Hidden dependencies include things like creating objects that send email messages or clients to cloud storage providers within modules that are developed to provide business logic capabilities.
Integrate applications across the enterprise for improved data integrity and consistent processes
Let’s take that a little further with an example: it might make perfect sense from a business standpoint to send an email to a guest after completing an order on an ecommerce website, but inside the ShoppingCart class is not the right place to set up all of the SMTP client code. Instead, think about sending an email as a service that the shopping cart needs to interact with.
Testing code that has hidden dependencies begins by refactoring them, and then creating a framework to treat them as services and the code that depends upon them as clients that consume them. Once a standard contract has been defined for those services, any object that meets the contract may be used by the client code. In this way, it is possible to create mock services that empower developers to more easily test their code.”
If you’re attending the St. Louis Days of .NET Conference on November 12th – 14th, be sure to reach out to Chris @coderandhiker and attend his session to find out how to apply dependency injection to eliminate hidden dependencies.
For additional information about St. Louis Day of .NET Conference or to register to attend, please visit http://stldodn.com/2015/.