I'm working on project, connected to hardware, especially sensors and actuators. Both sensors and actuators can be digital and analog. Example of all four types:
The question is, how I can represent these classes, without violating OOP principles, at least make design clear and logical.
One of my solutions is on the picture:
But I think this solution is "ugly"
Next solution is here:
This solution is also bad, because of redundant attributes and not uniform methods' names.
What do you suggest? Maybe there exists design pattern that solves my problem? Thanks for help!
Finally I came to solution. In my concrete case, Sensor and Actuator classes are just abstraction for data about current value and socket port number. So I decide to get rid of difference and make one class for both sensors and actuators. And discrete and continuous devices have it's own classes.