I read an interesting article from Krzysztof Zabłocki today.
It was about using protocol composition in Swift to handle dependency management. I’m not sure if I could use this at work but wanted to save this article for the future if I could.
Essentially what he outlines is creating protocols that enable behaviors and then having the implementations live in some AppCoordinator type object and your consuming types declare a dependency typealias
that is a concatenation of the various protocols you want and then you need only to inject the AppCoordinator type and it will handle providing only the types you need.
I like the part where you define protocols but I don’t know how scalable sticking all the implementations in an App-level type is. Perhaps his recommendation would be to have many domain specific types that implement the protocols you make.
I’ve had this tab open for months so rather than continuing to keep it open, I’m opting to use my blog to store it. Maybe that’s another post about a better way to handle notes about a topic or blog article without blogging. Maybe blogging is the way. I’m not sure…