Configuration to object, reflection or abstract factory?


(Luca Cavalllin) #1

I have a tiny IoT tool that given some configuration with sensor name and pin will read from these.
Let’s say I have:

sensors:
    temperature:
        pin: 3

I want to parse this configuration so a new temperature sensor is created and listening to pin 3.
What is the best way to do so? Reflection? Abstract factories? I want to avoid a long list of switch which I find not very elegant.

Thanks!