Chapter 18. Dependency injection and extensibility

 

This chapter covers

  • Building custom controller factories
  • Dependency injection with controllers
  • Using the dependency resolver with StructureMap
  • A survey of extension points

Knowing how to build maintainable software is important. Probably the vast majority of enterprise systems spend more time in the maintenance period of their lifecycle than their initial development. For example, imagine you’re developing a financial system that’s going to be in use for the next five years. It may take six months or a year to initially develop, but once it’s in use by the customer, it’ll enter an ongoing maintenance phase for the rest of its lifetime.

During this time, it’ll probably be necessary to fix defects, introduce new features, and modify existing features as requirements change over time. Being able to make these changes quickly and easily is important (especially if your client may end up losing money otherwise). Ensuring that a codebase is maintainable also helps new developers get up to speed on a project and understand how it works, even when the original developers have long since moved on.

There are many ways to help keep code maintainable, such as having automated regression tests and breaking large, complex programs up into smaller, easier to manage chunks.

18.1. Introducing dependency injection

18.2. Using DI with ASP.NET MVC

18.3. Summary