90% of the time, though, it's not an error in my logic; I just missed a semicolon somewhere or didn't capitalize a letter I should have. Though finding those errors is an important skill.
EDIT: I mean 90% of the errors I make are typos. Not that 90% of my time is spend looking for them.
I once spent hours and hours and hours trying to figure out what the hell was wrong with my program. Finally found a for loop with condition a>c rather than a<c and thus the code never entered the loop due to the zeroing of the counter. My god I hated my life that day.
Using the debugger is better than littering code with print statements. It seems daunting at first but it will save you so much time troubleshooting bugs.
I swallow my pride, drag over a colleague and walk her through the problem. About 2/3 of time, she'll point directly to the bug. The other 1/3, in explaining it to her, I find it.
over a colleague and walk her through the problem. About 2/3 of time, she'll point directly to the bug. The other 1/3, in explaining it to he
I've been programmer for almost 20 years now. Early on, the VP at the very small company I was working for, was an absolutely amazing person. When I'd get frustrated, he come into my office, grab a chair, and tell me to explain the problem, and what I was trying to do. He could barely use a computer let alone understand what I was doing, yet every time, I'd find the solution while I was explaining it. He taught me that just attempting to explain the problem, especially to someone who might have a difficult time grasping it, can force you to see what you're missing. To this day, when I get stuck, I go find some random, unsuspecting soul to render hopelessly confused, and I can't think of a time when it hasn't worked.
If you get the chance look into linting (cpplint, pylint, jslint, etc). It's what your Idea is doing under the hood there. The name is language dependent obviously, but you can find tools fit for basically all programming languages.
The other thing that may be useful is static analysis, which runs and analyses code to check for uncaught error conditions.
Seriously dude, if you spend 90% of your time hunting for semicolon, there is something wrong with your workflow. I'm not saying anything about your programming skills, which I'm sure are perfectly fine. But you are probably using the wrong tools.
I don't know what language you are using but it's very likely that someone developped a linter for it or, there is an IDE that has it already. A linter will check your code for this kind of mistake. If you want global code comprehension, try an Intelligent Code Completion module if it exists for your language. For example, I can import a class from another module and if I create an object with this class and add a dot right after, it suggests me the attributes and methods of this object. I don't have to switch from file to file to check for eventual typo.
Exactly. It can definitely happen where a slight typo actually forms valid code that only throws off the flow of execution slightly but it's very rare in my experience.
Holy shit yes, I have literally spend all day very slowly walking through every tiny bit of an OS my team was building for a class, only to find out that we forgot to uncomment a single line out. Literally 5 minutes before the deadline to turn in our code, it was fucking amazing when it worked.
Syntax errors are easy to find. The compiler even tells you where they are. Semantic errors are the difficult ones, eg adding instead of subtracting somewhere. Code that runs fine but gives the wrong answer can be a nightmare.
320
u/isfturtle Feb 09 '17 edited Feb 10 '17
90% of the time, though, it's not an error in my logic; I just missed a semicolon somewhere or didn't capitalize a letter I should have. Though finding those errors is an important skill.
EDIT: I mean 90% of the errors I make are typos. Not that 90% of my time is spend looking for them.