I’m looking to stop lurking the stack exchange community and actually participate a little more.
A little background, I am a student in University in my freshman year of my Computer Information Systems – Programming Track Degree.
So this issue I have occurred about a week ago in my freshman visual basic class. Now I have been programming on/off since I was 11, so I knew quite a bit of the basics already. I understand that I am a little farther ahead than some of the students, but I don’t ever talk about it or show off. I am very reserved about that kind of stuff.
Actually, this instance was the first time I openly talked in the class and asked a question. We were assigned a lab to add up every integer between 1 and the number entered by the user, and then display the sum. So if the user entered 10, it would display 5050. No big deal, so I get started.
Now this is where the issue happened. I realized that the user could enter a large number and cause an overflow error if we just used Int32s, which was all he went over in the class. I wanna figure out if he wants us to use Longs so we can calculate those higher numbers, or if he just wants to use Ints and catch the overflow.
So here I am, hand raised, about to ask the first question I have ever asked in this class. I said something along the lines of, “Would you prefer us to use Longs or to use Int32s and just catch for overflow.”
I kid you not the response I got from the class literally made me slide down in my chair. The Professor starts laughing and says “Use Int32s without checking for overflow.” And the whole class around me starting giving me weird looks and some even vocalized, “Why would you do that?”, “That’s stupid”, etc.
In my head, my question made complete sense. I mean, I’m not going to claim to be a programming god, but I thought that by now I had basic stuff like checking for errors understood. Why would not encourage us to do that / am I just being stupid?
All I know is that I was extremely embarrassed.
PS : He did already go over Try Catch in the class, and the Long data type. So the class would have the knowledge to check as long as they knew what an Overflow error specifically was.
TL;DR – I asked if we should check for overflow in a program in my class, Professor and whole class acted like I was crazy. Feel embarrassed.