-
Notifications
You must be signed in to change notification settings - Fork 63
Open
Description
To ensure more consistency across devices, I would suggest that the I2CBuilder and SPIBuilder classes get some abstraction. For example:
public abstract class AbstractI2CBuilder<I2CThing> {
protected int controller;
protected int address;
protected I2CDeviceInterface device;
protected I2CThing thing;
protected abstract I2CThing buildThing(I2CDeviceInterface i2CDeviceInterface);
public I2CThing build() {
if (thing == null) {
if (device == null) device = I2CDevice.builder(address).setController(controller).build();
thing = buildThing(device);
}
return thing;
}
}This would help ensure behavior across all the device classes using these builders, as there currently is some variation depending upon when the class was added to the code base (i.e. some builders throw exceptions when the device is already created and others do not)1.
I didn't find a whole lot of current devices that have "dual interfaces", so there may not be a lot of refactoring involved, but would likely help for future additions.
1Not a criticism by any means -- my own stuff gets out of date within days. 😏
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels