4 ms·
Remember when you were a new coder, and sometimes you'd see an off-by-one error that for the life of you, you couldn't track down? And after a long enough time
by mcantor 17y ago
Remember when you were a new coder, and sometimes you'd see an off-by-one error that for the life of you, you couldn't track down? And after a long enough time searching, you just gave up and added or subtracted one from the variable? I don't mean to badmouth these suggestions, because I have none that are better, but they all feel like that to me. Voo-doo fixes.
Just a thought.
- edw519 17y agoAnd after a long enough time searching, you just gave up and added or subtracted one from the variable? Don't pull that trick in my shop. Isolate your bug and fix it. Whatever is causing it is probably causing other bugs that will affect other people, including the poor sucker who has to clean up your mess.
- Novash 17y agoHe refers to the known floating point rounding error. You should not expect a 'new coder', as he put it, to trully understand floating point rounding errors because to understand it, you need to already be a coder with some experience.
- edw519 17y ago"You should not expect a 'new coder', as he put it, to trully understand..." Oh, but I do. If you don't understand it, figure it out. If you still don't understand it, ask. If you still don't understand it, sound the alarm, and we'll both sit down and figure it out together. And you will learn it. But please don't use "newness" as an excuse to leave shit behind. Excellence comes from doing excellently, whatever it takes.
- Novash 17y agoI talk like that because one of my first assignment in College when learning C was exactly a program to calculate change. And the inherent floating point erro causes the said 0.01 difference. I was fresh into C, third, maybe fourth class. You can be sure that no one had the least idea why that happened. Obviously, we all took the easy way out, used integers multiplied by 100 to work around it, but you couldn't expect me to figure out by myself WHY that was happening. This error, and the explanation of why it happened was the introduction to floating point class that we had after we saw it happen. It is just one of those things that you have to see working to understand (like recursion and pointers). I am always impressed to see how experienced people take a lot of knowledge for granted from others. It is not like you have never 'left shit behind' in your career. I would even daresay that if you pick the code you made six months ago, you will see that it could be improved in a lot of ways. Not because you wanted but because you didn't know better, mostly. This is pratically an axiom in the life of a coder. Please don't use "experience" as an excuse to diss the hardships of others. We were all there one day.
- mcantor 17y agoSorry--I should have been more specific. When I said "new coder," I really meant "new coder." I started programming when I was 9- or 10 years old, and thus worked without the onus of keeping my code clean for its future maintainers. As a victim of my own folly, however, I learned to avoid voodoo fixes by the time I was 14. :-)