I've created some custom types for example:
public class Temperature
{
protected double _celcius;
public Temperature(){}
public Temperature(double celcius)
{
_celcius = celcius;
}
public double Celcius
{
//sets & returns temperature in Celcius
}
public double Fahrenheit
{
//sets & returns temperature in Fahrenheit
}
}
and a similar one for Mass
, etc.
I also have a custom object, for example Planet
, which uses these custom types as properties.
[Serializable]
public class Planet
{
public int PositionFromSun;
public Mass Mass;
public Temperature Temperature;
}
What is the best practice for serializing Planet
in this case considering that Mass
and Temperature
may change slightly in the future (e.g. adding Kelvin
to Temperature
)? Should I have Mass
and Temperature
inheriting from a custom interface of something like IQuantity
.