Dependency Injection is one of the solutions when it comes to resolving dependencies in runtime. Let's look at the Wikipedia description:
Note
Dependency Injection is a software design pattern that implements Inversion of Control (IoC) for resolving dependencies.
Working with a Dependency Injection Container, you will see that it isn't only an IoC container but a set of software design patterns and principles that solves the problem of tight coupling.
Loosely coupled code enables us to write extensible code; testing becomes much easier with mocking the Subject Under Testing component dependencies; dynamic construction in runtime with injected dependencies; and of course maintainability, code that is easy to navigate in different modules, fix bugs, and add new features.
There are different patterns to inject dependencies to modules:
Constructor Injection
Property Injection
Method Injection
Service Locator
Others
Which one you choose depends on your...