We have talked about dependencies on Point-Free a bunch. Some of first episodes were about the concept of “dependency injection made easy.” In those episodes we claimed that a lot of the complexities of dependencies can be alleviated by embracing structs instead of protocols and by coalescing all dependencies into a single mutable value.
We took these ideas further by showing how dependency injection can be made composable and modular with the Composable Architecture. The notion of dependencies was baked directly into the core unit that powers a feature, known as a reducer, and from that we got all types of benefits, such as isolating our features into their own modules, sharing dependencies between isolated features, and even using different versions of a dependency for the same screen depending on the context it was presented. There was a lot of cool stuff we explored in those episodes.
And then most recently we kicked things up a notch again when we did a deep dive into how to design dependencies. That is, how do we allow 3rd party code run in our applications without it running amok. The more 3rd party code you drop into your code base the more chances there are to make your code untestable, strain the build systems, and accidentally break things like SwiftUI previews or even the ability to run in the simulator.
We want to continue this theme a bit more because there’s still something we haven’t spent a ton of time on, and that’s how to best wield our dependencies in tests. One of the main selling points of controlling dependencies is that it allows us to easily write tests for our features. But the power of those tests largely depends on we make use of the test dependencies, and there are some really cool tricks we can employ to increase the value of our tests.