Michael Long
Jul 20, 2024

--

The boilerplate needed for this simplistic approach is only suitable for handful of dependencies that are designed to be singletons (one single instance for the lifetime of the application).

Explicitly unwrapping the optional in the initialization code means that the system is not compile time safe. Forget to "register" a dependency type and the application will crash.

And finally, this approach fails to illustrate any way to alter or change the dependencies provided for mocking and testing purposes.

Not recommended.

--

--

Michael Long
Michael Long

Written by Michael Long

I write about Apple, Swift, and SwiftUI in particular, and technology in general. I'm also a Lead iOS Engineer at InRhythm, a modern digital consulting firm.

Responses (1)