Abstract base class

Hi,

Unfortunately I suspect that none of this is very encouraging to the OP.

I would suggest that if the behavior and the code to implement this behavior is largely the same across devices, you can create a base class that provides a full solution for the most common device but which includes virtual functions for the behavior which is different in other devices.

If the code to implement the largely similar behavior is actually quite different between devices then you would be better creating an abstract base class rather than the suggestion above - of a base class, because the base class code would be irrelevant in many cases.

The decision is really down to the extent of the device specifics -

  1. Everything about the devices is different, I just want to provide users with a class that hides this

Go with an abstract base class and create full implementations of classes for each device

  1. Mostly the devices are very similar, but there are some minor differences in how they are accessed and what they return

In this case there is an opportunity to provide a base class which provides a full implementation of the most common device and derived classes which implement/hide the differences through virtual functions.

These are often qualitative decisions, If I were you I would start with a base class that implements the most common device, then try and add additional devices through derived classes, if this starts to get awkward then its telling you that you would be better of with an abstract base class and individual implementations in the derived classes.

Duane B

rcarduino.blogspot.com