Essentially I've got a bunch of formulas in two giant methods in a class designed to do math transformations and evaluations to multiple inputs. Where the inputs are actually lists of inputs (as there are some sums involved too). Later on I want to optimize this code by utilizing GPU/CPU accelerated matrix multiplications and additions but for now I'm using the basic for-loops.
Lets say hypothetically i'd like to grow to several dozen cases and right now i have less than 10..
Something like:
enum EnumType {
SUPER_FUNCTION,
MEGA_FUNCTION,
..
}
float doMathStuff(EnumType functionType, List<float> a, List<float> b...) {
switch(functionType) {
case SUPER_FUNCTION:
if(situationA) {
switch(something else) {
}
} else {
switch(something else) {
}
}
return stuff;
case MEGA_FUNCTION:
for(..) {
if(situationA) {
switch(something else) {
}
} else {
switch(something else) {
}
}
}
return stuff;
...
}
}
My problem is that to support the functions I'm ending up with SEVERAL hundred lines of code in each of my switch statements which is making it rather cumbersome to go through. I shudder to think about maintaining this once I add more cases.
Any ideas as to how to keep this nightmare-in-the-making in check?
BTW: This is my own personal project and I have total freedom to do any changes.
enum
within a few seconds after the moment you define it (provided that you have properly thought about it up front), chances are you are messing up (you are using the wrong kind of abstraction). Use an interface and classes instead.enum
constructs do not really serve "future extensibility" that well.