mercredi 13 février 2019

Allow user to select implementation of code to use

I am starting a new project were we need to do some calculations based on some formulas, those formulas are valid for a limited interval for example year: 2017 to Year:2018 each couple of years they can change.

However we need to allow the user to select the "set" of formulas to use for example the user can use the year 2017 formulas or 2018

We're trying to figure out a way to avoid having code like

class FormulaA {
  double Calculate(Year selectedFormulaYear) {
      if(year == ...)
      else if (year === ...)
  }
}

Initialy i tought of doing a dll lib containing the formulas for each year and load them dynamicly in code. Is there a better way to this ?.

Aucun commentaire:

Enregistrer un commentaire