Hi David,

Yes, the approach you suggested was my default solution for this problem, default values do help you.

But I hope you understand that in complex apps there are classes with more than 4 parameters you need to pass. The more parameters you have, the better my approach fits.

As for me, writing less code (with keeping it understandable) appears to be a good approach. And in classic DI, not only do you need to pass many parameters when you instantiate an object, but you have to implement the init method with unnecessary self.value = value rows for each object you want to inject.

When it comes to writing in swift, I believe this approach looks good as the approach Apple uses in SwiftUI with environmental values.

Lifelong learner, iOS Developer striving for self improvement

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store