Your Worst "Gotchas" ever in programming

Started by
68 comments, last by Icebone1000 11 years, 2 months ago
I once had a school project in java dealing with Strings. Well, what better name for a class dealing with a project centered on Strings than String.java? Then when I tried to use methods of java's String class, the methods weren't there (because the compiler was trying to find the methods in my String class). Took two days to figure it out and it was only because I tried to rewrite the thing with more descriptive class and variable names after being inspired by a daily WTF article.
A penny for my thoughts? Do you think I have only half a brain?

Not-so-proud owner of blog: http://agathokakologicalartolater.wordpress.com/
Advertisement

Implementing a compiler front-end in Python. Write the prosaically-named 'SyntaxError' exception class. Realise that none of the methods on my SyntaxError class are accessible.

A little later, run 'pydoc SyntaxError' and realise the problem...

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

I don't recall the best.

But I'll tell you what I just fixed.

Updated an old project to new interface.

It failed on a custom string comparison.

Figured out the new project had optimizations all ON while dependencies didn't.

Previously "Krohm"

First time I used a treeset with a custom comparator and I couldn't figure out why it was loosing elements after calling sort().

Remember to mark someones post as helpful if you found it so.

Journal:

http://www.gamedev.net/blog/908-xxchesters-blog/

Portfolio:

http://www.BrandonMcCulligh.ca

Company:

www.gwnp.ca

Another vote for pass by reference issues. I once fixed a bug by adding a single '&' character to a function signature.

Probably everything when I'm kinda sleepy.

When I'm doing something and I'm not pretty focused, sometimes I go into "auto mode" and I eventually just lose track of what I'm trying to do and how.

So I code, code, code then something doesn't works and I spend 40min trying to figure out what I was doing (like literally, just trying to understand what I was doing the last 20 seconds), why, how I tried to do it and only then why it isn't working.

"I AM ZE EMPRAH OPENGL 3.3 THE CORE, I DEMAND FROM THEE ZE SHADERZ AND MATRIXEZ"

My journals: dustArtemis ECS framework and Making a Terrain Generator

Not calling the function I was debugging (and that was good for the first time and all along).

EDIT: I'm into some of those moments with Labview too. It's inherently parallel, so I'm sucking with queues and notifiers to avoid race conditions, sucking with messages getting lost and making workarounds to solve that.

Ah, yup, here's a gotcha: in Labview you draw wires (data flow) between icons (kinda like functions). I was debugging a bug for three hours, foaming at the mouth, breaking the keyboard in rage, when I accidentally noticed that the wire was hiding under the debugged construct (a case structure), and the wires from inside the case construct weren't actually connected with the outside. No wonder why values never changed. It was impossible to tell by eye, the wires where collinear, the little output "ports" were there on the structure, but not connected with the wire outside.

Yeah, I actually had one of these moments today...I implemented 3D sound with OpenAL, however it was clear to me that it didn't sound exactly right; like sounds switching from left ear to right ear randomly. I didn't manage to find what was wrong, so I closed the computer and went out...and on the cafe, I realized that AL_ORIENTATION would require 2 vectors, direction+upvector...just direction isn't logically enough no matter the API...so I returned home and sure enough, it expects 2 vectors instead of just the 1 I passed. Which, in OpenAL's C world means it expects a pointer to a 6-float array, which means it was just reading garbage for the up-vector. Don't you just love these kind of bugs?(OTOH, maybe I should have read the documentation more carefully :P)

Not one of mine but a former colleague's. I used to work on an OS written in BCPL. BCPL calls a function named TIDYUP when an application exits. If you define your own, it calls that rather than the default one. (Think of it as a bit like an automatically registered atexit function in C). My colleague spent a day and a half pulling his hair out trying to find why his TIDYUP function didn't seem to be called. Eventually he gave up and asked someone for help. The other guy took one look at his screen and said "It's because you've spelled it TIDUP".

My experience isn't interesting but is the only one I remember...

During last summer, when I started working on current project, at one moment I was implementing first collidable object. That time for tank I was using Vector2 Position and Vector2 Origin to tell spritebatch where to draw the sprite of the tank while keeping its bounding box as Rectangle. To be able to properly rotate tank, Origin must be set at the center of the texture itself. Position of tank was set the same as topleft point of its bounding box. I spent one week trying to figure out why was half of the tank going under the wall before eventually leaving it out of burnout and frustration.

2 months later, I remembered that Origin defines the point from which the sprite will be drawn...

This topic is closed to new replies.

Advertisement