Dependency Injection - locally testing a Python IoT component
Dependency Injection is a method of reducing coupling by removing the knowledge of where how that component's dependencies are created. The dependencies required in a component are provided to it rather than created by it. Removing this coupling lets us change the nature of the things a component relies on. In the case of this example: a hardware-specific dependency can be swapped with a virtual hardware version for testing or for alternative uses. References Sample Code: https://github.com/freemansoft/ESP8266-MicroPython Video Discussion: https://youtu.be/cHM4FydObmw Summary View Our code contains two different entry points. On the IoT device, main.py is the actual IoT based entry point. main.py can configure I/O pins based on some configuration information. It can then do the same for Servo pins. Finally, the main.py initializes a web server passing in the configured I/O and Servo pins. On our development machine or any...