I have device interface classes written in c# for electronic variable loads. They are mostly for DC devices. We got a new one that does loading for both AC and DC devices. I also have an interface named IVaraibleLoad
that lets me interact with them generically and group them if we are using several in parallel. From the perspective of the caller, interacting with an AC variable load is the same as interacting with a DC variable load. I would like to make two new interfaces IAcVariableLoad
and IDcVaraibleLoad
that each inherit from IVaraibleLoad
.
I do not think I should make the AC/DC mode part of the interface because most devices do not support the AC mode. I am stuck trying to understand how to make this happen.
If the above does not make sense, I will try to give a more generic example below.
A similar situation might be explained using the standard printer setup.
Assume I have several classes that each provide the low level functionality for an individual printer model, e.g., PrinterModelA
, PrinterModelB
, and PrinterModelC
. I have an interface called ICanPrint
which just exposes the bare minimum an external caller would need to print a text document. (This is where the analogy starts to break down.) Imagine that all these printer models implement ICanPrint
. Now we introduce an update and PrinterModelC
has the functionality to print a picture or a text document. To mirror my situation I make two new interfaces ICanPrintText
and ICanPrintPhotos
which both implement ICanPrint
. Now I have PrinterModelA
: ICanPrintText
| PrinterModelB
: ICanPrintText
| PrinterModelC
: ICanPrintText
, ICanPrintPhotos
.
Is there a better way to structure this?