Comments by "MrAbrazildo" (@MrAbrazildo) on "4 Notorious Beginner Coding Mistakes" video.
-
0:58, this is a common mistake, even among experts. Because we don't like to rely on the compiler ability to save us from a "performance mistake".
This is a simple 1, probably compiler does the right job of undoing it, whenever the initialization was unnecessary. But it's hard to put this practice on people's mind, on this niche. It's a cultural issue.
1:20, in C++ it's recommended to put: assert (number.length). It ends up not taking performance, because all those asserts might be ordered to not be executed, in 1 line of code - after debugging.
1:40, an easy to fix typo, immediately catched by the compiler, I wouldn't even take it as a worth mentioning error.
2:10, there's another problem: floating pointing should not be compared by exact values.
3:30, this for config. is so much more often than others, that I even wrote a macro for it.
0:01, this f() should return a bool:
return average - expected < abs (max_imprecision);
In C++ this would be result in bool. Or if a message should be send:
return "average is " (average - expected < abs (max_imprecision) ? "correct" : "incorrect");
I don't remember if this compiles.
1