Dependency injection is an essential tool when it comes to making code more testable. Instead of having objects either create their own dependencies or access them as singletons, it's the idea that everything an object needs in order to do its work should be passed in from the outside. This both makes it easier to see what exact dependencies a given object has, and it also makes testing a lot simpler - since dependencies can be mocked in order to capture and verify state & values.
[…]
Essential Developer: Until this Sunday, December 12th, you can join a free crash course to learn advanced techniques for testing both new and legacy Swift code — it’s a fast track to becoming a complete senior iOS developer! Click to learn more.
[…]
Support Swift by Sundell by checking out this sponsor:
[…]