You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@nanthony21 what is your intent here--to enforce common API across devices? Better code reuse?
I generally prefer shallow device class hierarchies with the ability for each device to implement different APIs depending on their capabilities. For example, a camera is a type of device that provides 2D imaging capabilities, but I might hesitate to subclass Camera from a more general 2D imaging device class. One implementation of this might look like:
camera = SomeCameraClass()
acq2d = camera.get_interface('acquisition2d')
image_data = acq2d.acquire_image()
It's a bit more verbose, but so much more scalable in that you can easily mix/match many different interfaces for your device to implement, while isolating the code for each of those. I'm happy to provide more detail on this, but from here the conversation dives deep into the "composition vs inheritance" debate and there are already a thousand articles on that topic elsewhere.
I like this idea of allowing a single device to implement multiple device interfaces. I may be mistaken, but I think that currently if you have a single hardware device that fits into multiple categories the only solution is to write a separate device adapter class for each interface you want to implement and then tie them all together using a Hub device.
Should the inheritance structure of device types be more hierarchical?
Something like: ?
DataAcquisitionDevice:
PositionedDevice: (Indicates requirement for affine transform):
...
The text was updated successfully, but these errors were encountered: