|
|
|
|
|
by z3t4
2697 days ago
|
|
Defensive programming is very effective in JavaScript. If the state is wrong, log, (core-dump) and restart. Trying to prove correctness statically is not a battle you can win in JavaScript. Instead enjoy getting things done. And let the bugs find themselves, using Murphy's law. For example: if(x<1) throw new Error("This should never happen: x=" + x);
If it can happen it will happen. So instead of support getting a call that some customers balance is negative, with defensive programming you not only prevented the bad state from spreading, you can also see why it happened. And fix it asap. Meanwhile if you trusted the static analysis good luck and have fun debugging something after-the-fact that "couldn't" happen. |
|