Factory: Multiple Module Registration

<p>When you want to use a dependency injection system like Factory with multiple modules you often run into a &ldquo;Who&rsquo;s on first&rdquo; dilemma.</p> <p>Let&rsquo;s say that ModuleP specifies an abstract<code>AccountLoading</code>&nbsp;protocol.</p> <pre> // ModuleP public protocol AccountLoading { func load() -&gt; [Account] }</pre> <p>Moving on, we have an accounting module, ModuleA, that displays our accounts, but needs one of those loaders to load them.</p> <p>Finally, we have one more module, let&rsquo;s call this one ModuleB, that knows how to build loaders of any type that we need.</p> <p>Note that ModuleA and ModuleB are independent. Neither one knows about the other one, but both have a direct dependency on ModuleP, our master of models and protocols.</p> <p>This is a classic modular contractural pattern.</p> <p><a href="https://betterprogramming.pub/factory-multiple-module-registration-f9d19721a31d"><strong>Read More</strong></a></p>