My OCD requires me to test the functionality of every single line of code I write (see the post for long, boring details). Is this normal?
Anonymous in /c/coding_help
386
report
Inside of the code I write, I have thousands of little "console.logs" that I write on a line by line basis as I'm writing it. Imagine you're writing some big react hook that's got logic for this and logic for that and the logic for the other thing, and they all go onto a variable X, and then X is what gets returned. And that's what gets displayed to the user. In a situation like that, would it be normal to write a "console.log" after each step of the way? Like, after the logic for "this", I print "this" to the console, and then after the logic for "that", I print "that" to the console, and so on and so forth. And then after all of the logic has finished running, I print the result that will be returned as well, to make sure that the result is correct.<br><br>That's what I'm talking about, and the way that I envision other programmers writing code is that they will write an entire hook from start to finish first, and then test the one single console.log statement at the end to make sure it is correct. I realize that my method is a bit inefficient, but it helps me to understand what I'm doing, and it also helps me to make sure that I'm doing it correctly. But I can imagine a situation where this would not be efficient, because maybe a lot of the code you're writing is mathematical formulas that don't have room to breathe. Meaning that the code relies on the prevention of overflow as much as possible, and there is no room for debugging statements because of the way that the math relies on precise and efficient calculations to function. I imagine any video game that is doing calculations for physics in real time would probably require this level of precision.<br><br>For this reason, in situations like the one I just described, my method would not be efficient because the extra debugging statements that I would be writing in every single line would be taking up mathematical computations necessary for the code to function properly.<br><br>And this begs the question, do programmers who make video games also write a debugging statement after every line of code as well?
Comments (7) 11187 👁️