I am redesigning an application that is used for data acquisition. We have a base class called Sensor
which is more or less as follows:
public abstract class Sensor
{
public virtual String Name { get; }
public virtual UnitOfMeasurement Unit { get; }
public virtual int SamplingRate { get; }
public virtual CalibrationModel Calibration { get; }
}
Each of its subclasses has a "hardcoded" value for each property. For example EmgSensor
has "EMG" as Name, "UnitOfMeasurement.Volt" as Unit, etc.
Our current system has this problem I am trying to solve: Each time that a new actual sensor hardware is developed and added to our portfolio, we need to do the following "shotgun surgery":
- Create a new
Sensor
subclass; - Perform some scattered, minor changes on the rest of the system (due to depencencies, etc.);
- Release an update to our client base.
I understand that each physical sensor (the hardware) is a conceptual unit, and as such should be able to be "plugged" to a running system so that it doesn't need to be recompiled.
On the other hand, if each subtype of Sensor
is to be considered a class, how could I create a "dynamic" class from, say, configuration files? Should I be using the Factory pattern? Is there any other, more suitable way of achieving what I need?
I am using C# (although I think this is incidental to the question).
Aucun commentaire:
Enregistrer un commentaire