SOMEONE Code Reviewed Hazel, My Game Engine feat The Cherno and Nathan Baggs
Posted by sarkie@reddit | programming | View on Reddit | 7 comments
Posted by sarkie@reddit | programming | View on Reddit | 7 comments
ItsBinissTime@reddit
Don't write code you're not using, not just because it saves time, but because unused code can hide bugs.
I once chased down a bug in an engine under development that was caused by vector subtraction being a copy/paste of addition and the author forgot to change the sign. It just hadn't been used until recently, and naturally when I used the existing operator, I assumed it must work.
dukey@reddit
That's why you use glm or some variant, rather than re-invent the wheel lol
Narase33@reddit
Do you understand what an example is?
dukey@reddit
What kind of stupid question is that? Sure, but it's also a lesson in re-inventing the wheel when mature libs to do what you want are available. That is as much as a fatal mistake as well as assuming untested code actually functions.
kippertie@reddit
I agree with you in principle: YAGNI is very useful in software dev, but your example is somewhat shallow. For something like a vector class that implements add it would be strange to not also include subtract. Your issue of subtract being incorrectly implemented would have been caught immediately with unit tests, before it was even committed to the code base.
ItsBinissTime@reddit
It happened. It demonstrates the problem.
ItsBinissTime@reddit
Express the lifetime of the app object with a local scope (and use unique_ptr if it must be dynamically allocated).