I used dependency injection in some projects but I didn't fully understand why. I think it is partly to facilitate TDD - if we use dependency injection then many dependencies of the software can be injected/"mocked" and like that we can test them without having the dependency, for instance, an underlying data set that is mocked during the tests instead of supplied as it actually is.
Is this correct or did I misunderstand?