Rob Amos - Dependency Injection with a Service Locator pattern

Rob Amos explores dependency injection in Swift, contrasting traditional constructor injection with the service locator pattern and its limitations. He walks through his open-source library 'Depends', demonstrating the DependencyRegistry, DependencyKey, and a custom @AppDependency property wrapper inspired by SwiftUI's @Environment. The talk covers practical testing benefits with mock dependencies, trade-offs around runtime versus compile-time safety, and advanced patterns including hierarchical registries for multi-scene macOS apps. From Melbourne CocoaHeads No. 152    • Melbourne CocoaHeads No. 152   Chapters: 0:00 Intro 1:21 Traditional DI Problems 4:57 Service Locator Concept 8:03 Introducing Depends 16:52 Property Wrapper Internals 23:44 Testing with Mocks 27:07 Benefits and Trade-offs 34:43 Hierarchical Registries 37:45 Outro --- Melbourne CocoaHeads — a community of iOS & macOS developers in Melbourne, Australia. https://www.melbournecocoaheads.com/