Design using readonly class in C #

Small design issue here. I am trying to develop a calculation application in C #. I have a class, let it call InputRecord, which contains 100 fields (multidimensional arrays). This class InputRecordclass will be used in a number of CalculationEngines. Each CalculcationEngine can make changes to several fields in the InputRecord. These changes are the steps necessary to calculate it.

Now I do not want the local changes made to InputRecord to be used in other classes of CalculcationEngine.

The first solution that comes to mind is the use of structure: these are value types. However, I would like to use inheritance: each CalculationEngine needs several fields related only to this engine: it has its own InputRecord based on BaseInputRecord.

Can someone point me to a design that will help me accomplish this?

+3
source share
3 answers

If you really have a lot of data, using structures or general cloning methods may not be very economical in space (for example, it will use a lot of memory).

It sounds like a design where you need to have a "main store" and a "diff store", just like a DBMS, you have data files and transactions.

, , , , - .

+2

. ( ).

, . , .

+2

You can declare the Clone () method in BaseInputRecord, and then pass a copy to each CalculationEngine.

+1
source

Source: https://habr.com/ru/post/1740286/


All Articles