Honestly, this is a good rule for programming in general. With user input, make sure it’s in its own area where it can’t interact with anything else and make sure to read and process in such a way that it can’t fuck with the operation of the program.
In my first CS class, the professor announced an extra credit project due at the end of the semester. It was to create a formatted terminal calendar given a year from user input. I finished it after learning about condition but before I learned about classes… or functions… or loops… or searching the internet… partially. I searched how leap years worked, but didn’t bother to search for code (Stack Overflow didn’t exist yet)
Anyway, long ass program with each month hard-coded with 7 possible calendars for each month depending on the first day of the week. Lots of copy and paste. Professor was speechless, but accepted it.
One of the first real programs I wrote was a program to display telemetry data from a CAN bus. I was on the solar car team at uni, and we wanted to be able to view the data from the various systems live during the race. The CAN network was connected to a CAN-ethernet converter, which sent UDP packets over a wireless ethernet link to our lead car. I had no experience with networking, or UDP or CAN at all, but I had some documentation and a lot of free time, so I got to work.
Each device on the CAN network had a bit mask to identify it. For example, the bit mask for the motor controller might have been 0x1200. This meant that any packet starting with 0x12 belonged to the motor controller. For example, 0x1201 was one type of message, and 0x1202 another type, but both belonged to the motor controller.
There was specific logic for each device on the network, so you needed to first figure out which device owned a packet using the bit mask, then apply the relevant logic to decode the packet.
Looking back, I realise the correct way to approach this would be to have a list of bit masks:
Then simply bitwise & any incoming packet with 0xff00, and lookup the result in the list of bit masks.
Not knowing better however, what I actually did was create a giant dictionary of every possible packet value, so I could lookup any packet and determine which system it came from. This was so repetitive that I had to make use of my newfound super-power – vim macros – to complete the 8000 line dictionary…
First semester of my cs degree, it was around 50/50. After 3 semesters very few women were left. Spoiler: it was not because they could not handle the courses.
It was another time, but the first field my mother went into was IT. She dropped her punch cards on her way to the computer and had to explain to the teacher that she would need time to put them back in order. His reaction?
“Women have no business in my class, go do the nursing program instead.”
I had a shitty old (late 60s) boss in 2008 who once interviewed a female engineer straight out of college.
Most interviews he gave took like 25-30 minutes. He spent an hour and a half alone in the conference room with this young woman.
After she left he said something to the team like “Sure wouldn’t mind seeing her around the office every day eh? We’re not hiring her of course. Women don’t have the head for this work.”
This same guy had me block all news sites except Fox News (I was the IT director). He was fine with his employees reading the news as long as it was Fox (I ended up teaching a couple of my coworkers how to use proxies).
At least refactoring the code can make the bug easier to find. What I hate is when I spend hours looking for a bug because I missed a single line in some documentation and misunderstood how something in the project worked, that always hurts.
programmer_humor
Oldest
This magazine is from a federated server and may be incomplete. Browse more on the original instance.