3

Looking at a lot of MVC source code, I notice that most MVC projects (especially larger projects) implement dependency injection in one way or another.

I have two questions. First of all, is it feasible to create a large project without using dependency injection? I understand dependency injection makes large projects a lot easier to maintain and unit test. But how much more complex would a project be that didn't use dependency injection?

Second, when scoping the requirements of a new project, what criteria should I use to determine if I should use dependency injection? It requires a lot of initial setup and sometimes it seems unnecessary for a quick simple program.

Icemanind
  • 47,519
  • 50
  • 171
  • 296

1 Answers1

1

There is no such thing like wrong or useless dependency injection so i recommend to use it always :)

It makes your code much more extensible, easier to test and also more readable (because the dependencies are clearly visible).

Second, when scoping the requirements of a new project, what criteria should I use to determine if I should use dependency injection?

  • You can avoid it for prototyping or if you are building something which will be not used in production environment.

it feasible to create a large project without using dependency injection?

  • yes but i do not recommend to do this

It requires a lot of initial setup and sometimes it seems unnecessary for a quick simple program.

  • Asp.MVC has good built in support for dependency injection. You can setup it pretty quickly. It is only matter of a nuget package instalation.
Marian Ban
  • 8,158
  • 1
  • 32
  • 45