James Ross, on 27 October 2015 - 11:31 AM, said:
That could well make the program behave like a 'boiling frog'.
In case you are not familiar with this : if you put a frog in boiling water, it will jump out as it senses the change of temperature.
But, if you put a frog in cold water and then slowly heat it, the frog will never sense the change in temperature and will slowly be boiled to death without ever 'realising' what happened.
That is the risk here as well : by adding small items bit by bit there will never be a clear detoration in performance, but one day we will wake up and find the program has really become much slower. There is no way back from that once that state is reached, because there isn't a single particular change which caused it, it's just the culmination of many small steps.
Furthermore, making these additions optional need not be bad for the structure of the program at all: it may well entice the programmer to concentrate these additions in a limited number of clear methods, rather than to spread these out in small blocks of statements all over the program.
That's what has been done with much of the code for Train.cs and AITrain.cs : rather than having hundreds of 'if' statements checking for activity or timetable mode, a clear cut has been made using child classes and override methods where necessary.
The same could be done here: if these calculations are part of, say, the wagon class, then if this option is set a 'child' class is used which holds the methods for these calculations. Such a method of 'splitting' according to options also would make it easier to implement different calculations as required for different types of couplers.
Regards,
Rob Roeterdink