QuirkyCort / gears

Generic Educational Robotics Simulator
Other
65 stars 41 forks source link

Inconsistent style and excessively long if-else branch chains #123

Open LukasDrsman opened 1 year ago

LukasDrsman commented 1 year ago

Several parts of the code in public/ subfolder contain excessively long if-else branch chains, which could be reduced simply by proper usage of switch-case labels instead of branching (e.g. type recognition in Robot.js). Additionally, inconsistent style is used for function definitions and calls (spaces vs no space before parentheses of functions and their definitions).

QuirkyCort commented 1 year ago

In the "if-else" vs "switch-case" war, I generally stand on the side of "if-else". It's a stylistic preference. Don't want to get into any arguments over why I prefer one over the other, but it should suffice to say that I'll accept code written in either styles, but won't change working code from one to the other.

...for that matter, a lookup would be much better than either "if-else" or "switch-case", but it'll require some of the component classes to be changed.

As for the inconsistent spacing in function definitions, that's my bad. I'll fix it if I see it.