It is required to perform previously unknown calculations in C # algorithm for which it is necessary to calculate the incoming parameters. The algorithm itself is stored in a database. How to make it better? I have not come across dynamic calculations yet.

For example:
Psychological testing is conducted and each test has its own algorithm, for example, 1-5 (1 point) 6 and 7 (2 points) and the algorithm is always different for each test. Now it is implemented on Lua, but I realized that this is not an ideal solution. A quickly implemented crutch.

  • 2
    There is a spherical horse in a vacuum, it is required to calculate its density. More detail you can. Wang on vacation. - Dmitry Chistik
  • Give at least a couple of examples. - Monk
  • Something like your language in the program? - MaximK
  • those. there is a psychological testing and each test has its own algorithm, for example, 1-5 (1 point) 6 and 7 (2 points) and the algorithm is always different for each test. Now it is implemented on Lua, but I realized that this is not an ideal solution. A quickly implemented crutch. - Asa Fornote
  • Wait, but what may not suit you Lua, maybe you just use it wrong? For the given example with points, Lua is more than enough, why do you want to bring more JavaScript inside? - Kromster

2 answers 2

Perhaps you fit scripting languages ( in English ) there are many and different.

You include the script engine in the program and associate it with the functions in your code. Then you can download and execute a script that can do the calculations and access the functions provided.

  • Can I link to Google’s V8 project and execute javascript inside the program? - Asa Fornote
  • For the given example with points, Lua is more than enough, why do you want to bring more JavaScript inside? - Kromster
  • Those. Not really, I implemented Lua in the program, for me this was done by a second developer who is no longer involved in the project. It works this way Lua performs with JavaScript in the Web browser component on the form and returns the interpretation text. - Asa Fornote
  • And JavaScript needs something to display Russian text, I was told that Lua does not support it. - Asa Fornote
  • one
    @ FedorovAleksey Perhaps you should face some more specific problem, formulate a specific question on it and ask it here. Judging by the description, you need to differentiate the system so that the parts become more independent. And do not drag everything into Lua, according to the described example, you have to feed only test numbers and selected points to the input, and give the total figure, you can attach the text outside. - Kromster

I see 3 options:

  1. Scripting languages ​​(Python, for example)
  2. If there are not too many varieties of algorithms, then ask them all directly in the code with different parameters (I think that one test for questions has ab points, and another test for questions km y points, these are not different algorithms). I would do that.
  3. Deliver processing logic in SQL