I am beginning to see the light.
One of the reasons why Dependency Injection is so powerful is because of its ability to be tested. This may be common knowledge to the reader, but it is different when you are building it for the first time.
It’s like thinking about Karate. It can be described as a martial art, with disciplines, and there are kicks and punches involved. However, it is one situation knowing you have to kick and punch, and an entirely different situation to actually kicking and punching. Not to mention the practice behind it.
Same situation here, I know I need tests. I know abstraction is helpful for flexibility, preventing code rot, and for testing as well. When it comes to implementing the ideas together, well it is challenging.
Creating the interface is simple, creating the real class that implements that interface again straightforward. Now, when it comes to creating the mock class and its tests. That is challenging.
Probably the biggest hurdle is that I am writing the abstraction last as opposed to writing it first along with the tests. This helps with design and bugs later, though without the experience of building something it is tough to know what to test for and how to test to begin.
It is possible I am just being lost in all of the abstraction for the moment.
Like many situations in software. After practicing and practicing the situation becomes clearer, slowly but surely.
Best,
Merl