Just here trying to understand the dependency inversion principle and how it actually relates to the ItemStore example in chapter 10. The book stated that by initializing the itemStore attribute in the app delegate instead of the view controller itself, we are removing dependencies. But I don’t quite see the difference.
In my mind this is how it goes.
If initialized inside of app delegate, you save the initialization code. However, if for whatever reason, we decided to not use itemStore as our data source, we still have to remove the declaration of var itemStore: ItemStore! inside of the viewController, and swap it out for a new data source attribute.
On the other-hand, if we decided to initialize the itemStore within the controller, when it comes time to swap it out for something else, the only additional work we are really doing is removing the attribute, swap it out for something else, and removing the initialization code. A bit more work, but not a lot more.
Perhaps this example is too small for me to see the significance. What are your perspectives?
Thanks in advance