From the course: Learning ASP.NET Core MVC

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Increase maintainablility with dependency injection

Increase maintainablility with dependency injection

From the course: Learning ASP.NET Core MVC

Start my 1-month free trial

Increase maintainablility with dependency injection

- [Instructor] One of the tenets that drives the ASP.NET Core's framework design is a focus on being able to create applications composed of lightweight and modular components that each do one thing well. One of the main ways it does this is through built-in support for dependency injection, a development pattern which encourages loose coupling between components. To understand the value of dependency injection, let's use the example of the configuration settings that I introduced earlier. In its current state, this code is very tightly coupled to the configuration API since it has to know everything about where these configuration values come from and how to read them from the configuration object. However, all this method really needs is a flag to tell it whether or not to show that developer exception page. Why should it care that the value from this flag comes from an environment variable or a JSON file or even a configuration setting at all? What if this method depended on a…

Contents