From the course: Learning SOLID Programming Principles
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
Dependency injection and application configuration - Python Tutorial
From the course: Learning SOLID Programming Principles
Dependency injection and application configuration
- [Instructor] It's not possible to avoid all references to concrete classes. When the application runs it'll need to use concrete classes. Somewhere, somehow the concrete class has to be named. Application code should refer to abstract classes. This leads to the idea of injecting the concrete class names into the application. It means the concrete classes are only mentioned in a separate configuration file. In Python it's relatively easy to provide the concrete class names via a configuration file, and I'll show two techniques for this. The first will be via a settings module an application can use this module to find the concrete class to use. The second will be an object factory class that builds objects based on some runtime configuration. One technique for injecting concrete class names is a settings module, it provides the names. The settings module becomes a configuration file, and these can be written in Python.…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.