My experience is that static constructors can be messy. In addition, if you want to test logic by writing unit tests to mock serial communications, this architecture will make it harder.
An alternative would be to have a Device class with a constructor that takes some configuration arguments (which serial port to use, for example), and have two real devices that you would communicate with as public static end fields of the class. Something like that:
public class Device { public static final Device Device1 = new Device(...); public static final Device Device2 = new Device(...); public Device( ... ) { } }
To make tests even easier, you may have a device interface that is implemented by this device class - this helps to make the development cycle more rigorous if you can test the logic of interaction with devices without having to deal with the device itself.
source share