Note that there are some explanatory texts on larger screens.

plurals
  1. PODynamic calculation over dataset by providing logic externally
    primarykey
    data
    text
    <p>I am doing some mathematical operation on a data set. As per the requirement of the project, the mathematical formula/logic can be changed at any time. So I am thinking to keep these formals out from the Java code, may be in config file. Below is the sample config file-</p> <p><code>formula.properties</code> file-</p> <pre><code>formula_a=(a+b)/(7*c+b^2) formula_b=(a^(1/2)-formula_a*13) formula_c=spilt_time(formula_b,a,b) </code></pre> <p><code>Calculator.java</code> (A dummy Java file, which may not be correct as Its for demo purpose only)</p> <pre><code>public class Calculator { private final static String FORMULA_A = "formula_a"; private final static String FORMULA_B = "formula_b"; private final static String FORMULA_C = "formula_c"; public static void main(String[] args) { long a = 1738342634L; long b = 273562347895L; long c = 89346755249L; long ansFromFormulaA = applyFormulaFromConfig(FORMULA_A, new long[] { a, b, c }); long ansFromFormulaB = applyFormulaFromConfig(FORMULA_B, new long[] { a, b, c }); long ansFromFormulaC = applyFormulaFromConfig(FORMULA_C, new long[] { a, b }); } // spilt_time is used in formula_c public static long[] spilt_time(long[] params) { final long[] split = new long[2]; // Some logic here which is applied on params array and answer is pushed // into split array return split; } private static long applyFormulaFromConfig(String formulaName, long[] params) { long ans = 0L; // Read formula from property file here and apply the params over it and // return the answer return ans; } } </code></pre> <p>Please help me to design a solution for this.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload