Link Time Dependency Injection

Have you ever been in a situation where, because of how the code is structured, it’s practically impossible to inject a dependency into the component that needs it? Even global variables - ubiquitously reviled for their ability to do “spooky action at a distance” - weren’t spooky enough.

In this article, I’ll share a technique I discovered while working on a WebAssembly-based CAD package back in 2022 that allows for dependency injection at link time. This technique is particularly useful when traditional dependency injection methods aren’t available or practical.

6 Likes