lundi 14 mai 2018

Manage multiple variable in one, big if-else

I have to solve problem with some Word's like editor and it's codes, witch return some logic. Now I have over 4000 variables:

string code1 = "onePlusOne";
string code2 = "onePlusTwo";
...
string code4000 = "onePlusFourThousands"

and the same number of logic if-else statements:

if(code == code1)
    return 2;
else if(code == code2)
    return 3;
...
else if(code = code4000)
    return 4001;

Client can paste code into editor to get value, for example:

"Some test, #onePlusTwenty# some test."

..and the result will be:

"Some test, 21 some test."

My problems are:

  • over 4000 variables in code,
  • over 4000 lines of if-else (with returns it's over 10 000 lines).
  • contradiction with SOLID :)

I was thinking about store those codes in database (but this solve almost nothing), also I can sort those codes into groups (but this only will help me to split if-else into many others if-else).

I will be grateful for any idea how to mange this.

Aucun commentaire:

Enregistrer un commentaire