Posts

Showing posts with the label Dependency Injection

Dependency Injection - locally testing a Python IoT component

Image
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...

Spring.net configuration in App.config

I recently (10/2012) converted my TFS build monitor program to be Dependency Injected using the Spring.Net container. I did this because I wanted a no-code way of setting certain parameters and of specifying a build device management class without having to convert a configuration parameter into a class name. I instead injected the spring object with the same name as the configuration parameter using Spring.Net's built in facilities. Spring.Net is moving towards more annotation based configuration but the XML configuration is still widely used and powerful.  You can easily configure Spring.Net in XML with markup inserted into App.config.  The first thing to do is to tell the system that there are going to be some spring.Net sections added to app.config.  This defines two sections, contexts and objects.   context is the section that describes where to find other pieces.   objects  is the section that contains the actual object wiring.  Additional sect...