Today I had a minor epiphany. I was working on a unit test on a class method, and had a rather annoying time with it because the class (a ViewModel) uses an instance of a different class (a repository) to do things. There is a coroutine involved, so things got a bit hairy until I watched a tutorial video that essentially suggested a dependency required for testing to be added as parameter for the class’s constructor.
This required me to modify the actual class, and when I was done I just realized what this is about. It’s dependency injection!
Sure, I’ve written about it before (in an attempt to understand it), but it’s only when I’m actively working on adding unit tests that I experienced the actual value of D.I. Pretty neat!