This site is no longer active and is available for archival purposes only. Registration and login is disabled.

Stupid Programmer Tricks


Stupid Programmer Tricks

Postby fzammetti » Jun 13, 2002 @ 9:22pm

I was going to reply in the thread, but I thought this might actually be more entertaining...

Phantom made a comment to me in another thread (which I understood was a joke by the way, even before you told me it was!) and it got me thinking... what's that absolute stupidest mistake I've ever made in programming?

We've all made 'em. You know, the things where when you finally get the answer you yell out "How the HELL did I miss THAT for EIGHT HOURS?!?". Or the ones that when you finally figure it out make you so embarrassed that you look for the nearest tall building to throw yourself off of?

If you claim to never have made a stupid programming mistake, you have NEVER PROGRAMMED!

So, why not have some fun with it? Why not tell the world (such as it is in ONE forum on ONE web site!) how dumb you can really be sometimes... tell us the stupidest programming mistake you've ever made!

I'll start off...

Back in about '86 when all I did was code assembly day and night on my trusty C64, I had this one demo that kept crashing hard on me every time it came to this one chunk of code. Well, I narrowed it down to no more than 20 lines of code, and I then sat staring at it for no less then three days. Couldn't find the problem no matter what I tried.

What did it finally turn out to be?

There was an opcode called LDX, load the X register. Well, I had LDY, also a valid opcode, but quit a bit different.

Need I say more?

So come on guys, throw 'em out there! Let us all have a good laugh at your expense!
...and so I said to Mr. Gates: "$640 billion should be enough for anyone!"
User avatar
fzammetti
pm Insider
 
Posts: 1496
Joined: Jun 4, 2002 @ 6:21pm
Location: Omnytex Technologies


Postby Hosed » Jun 13, 2002 @ 10:17pm

You know that lovely little ; required at the end of classes, structs, and enums?

when I was first learning C++ I was writing this huge class late at night and forgot all about the semicolon. Then proceeded to spend 5 hours trying to figure out what the compiler's error message meant.
User avatar
Hosed
pm Member
 
Posts: 249
Joined: Jan 3, 2002 @ 2:51am
Location: Montana, USA


That reminds me

Postby fzammetti » Jun 13, 2002 @ 10:21pm

You made me think of a general thing that happens to this day, I'm sure to all of us...

Don't you just love when you forget a semicolon, or worse yet, a closing brace? I love when I get 300 or so compiler errors that can be fixed by adding ONE SINGLE CHARACTER (of course, it's usually closing a block of code 4,000 lines back, so actually figuring out where to place it is a nightmare... yes, I know, IDE's will tell you, blah!)

Of course, when my boss asks me what I did today, I can tell him "I squashed 300 bugs!" (which took 30 seconds, then spent the rest of the day surfing the web).
...and so I said to Mr. Gates: "$640 billion should be enough for anyone!"
User avatar
fzammetti
pm Insider
 
Posts: 1496
Joined: Jun 4, 2002 @ 6:21pm
Location: Omnytex Technologies


Postby Pam » Jun 13, 2002 @ 10:50pm

Back in college I was up late working on a class project. Basically we had to process a set of strings and produce various output.

We had to write a strcpy function in C using only pointers and after 3 hours of crashes and headaches what did I forget? All together now, "Null terminate the string!"

It's like locking your keys in your car. You do it once, then never again.

Pam
All the easy problems have been solved.
User avatar
Pam
pm Insider
 
Posts: 449
Joined: Jan 24, 2002 @ 10:30pm
Location: Ohio


Umm...

Postby fzammetti » Jun 13, 2002 @ 10:57pm

I've locked my keys in my car more than once.

(Oops, did I just type that?)

Worse yet, I locked them in my HOUSE. Breaking into your own house is not fun, especially when you have an alarm system.

I should add this one too...

A couple of months ago I was working on a message board system done in Active Server Pages, ADO to a SQL Server database. Well, I called up the page to display the list of forums, and the server seized up harder than a '68 Dodge with no oil in the pan.

What did I do wrong?

Gee, you know when you do something like:

Do While Not objRS.EOF
Loop

And your iterating through the result set?

Lemme put it this way: it's always a good idea to move to the NEXT RECORD!

(Man I hate infinite loops)
...and so I said to Mr. Gates: "$640 billion should be enough for anyone!"
User avatar
fzammetti
pm Insider
 
Posts: 1496
Joined: Jun 4, 2002 @ 6:21pm
Location: Omnytex Technologies


Dang compilers

Postby Ionitor » Jun 13, 2002 @ 11:14pm

I had a problem that I had been working on for my own interest when I was first teaching myself C++. I developed a templated class for the problem because it was a large numerical problem, and could conceivably need larger-than-64-bit integers later in the game.

Well, my class had some stupid little bug in the code to travel and operate on a binary tree. I can no longer remember the exact bug, but it seemed straightforward enough at the time. I fixed it, recompiled, and the same bug popped up. I thought, "Well, there must be a different bug somewhere else in the code." I looked around, found a few bugs here and there, but nothing that would fix the problem. I spent few days working on it, then finally gave up, since it was just for my own interest and I had more important things to spend my time on.

A year or so later, I looked back at the program. The bug still didn't make any sense, so I spent some more time stepping through the code. Eventually, I noticed that the debugging code I had put in wasn't running--I would create a variable, increment it, and the variable never seemed to exist. Finally, I came to the conclusion that the code I was looking at was not the code in the program. It turned out that Visual C++ 4.0 had a bug in it that would ignore changes to template class files, so after any changes, you needed to use the "clean" command before recompiling.

Since then, the first thing I do whenever there's a difficult bug is just recompile my whole program. It continues to save me hours of problems to this day, even with the most current compilers.

-Ionitor
Ionitor
pm Member
 
Posts: 15
Joined: May 17, 2002 @ 9:31pm


Postby Hosed » Jun 14, 2002 @ 1:08am

Haha, I love ASP. "We'll just add this simple bit of code here and now lets see how this runs..." 10 minutes later. "Ooops, locked up the server again"

Ionitor: I've run into a bunch of bugs like that. I too immediately rebuild the whole project alot.
User avatar
Hosed
pm Member
 
Posts: 249
Joined: Jan 3, 2002 @ 2:51am
Location: Montana, USA


Postby Hosed » Jun 14, 2002 @ 1:19am

Here's another one. When dealing with RECTS getting the width and calculating it as left - right instead of right - left .

"Why's my blit failing?"

I do this ALL the damn time.
User avatar
Hosed
pm Member
 
Posts: 249
Joined: Jan 3, 2002 @ 2:51am
Location: Montana, USA


Postby Dan East » Jun 14, 2002 @ 4:23am

Wow. I haven't the time, nor has the server the HDD space, for me to start listing all of my stupid mistakes. :) I've already posted my most recent (where I chose a name for a new function and used it for the declaration and call, and then used a different name for the implementation. I scratched my head for 15 minutes wondering why the linker couldn't resolve that function, and started playing around with the calling convention before I figured out my stupid mistake).

A student at YSU made the typical newbie mistake of reversing the last two parameters of a for statement. She worked on it all day trying to figure out what was wrong with her code (on a Unix workstation, so no interactive debugging was available). I only had to glance at it to see that glaring mistake. :) To this day I make a comment like "//This is not a mistake" when I do "abnormal" things in for loops.

Dan East
User avatar
Dan East
Site Admin
 
Posts: 5264
Joined: Jan 25, 2001 @ 5:19pm
Location: Virginia, USA


Postby refractor » Jun 14, 2002 @ 10:22am

I wrote a "clearscreen" function once for DOS. Every time I tested it on its own, it worked a treat. Every time I tested it in the application it hung and dropped dead. Turned out that calling my test application "CLS.exe" wasn't such a good idea :D

When I worked in London there was somebody (not me!) that did:

update customer set surname="Smith";

and ran it by mistake (forgetting the where clause)... and consequently changing the surname of 20,000 people to "Smith" :)

Luckily we could feed all the data back in from the mainframe, but it caused a bit of a panic :)
User avatar
refractor
pm Insider
 
Posts: 2304
Joined: Feb 5, 2002 @ 1:12pm
Location: Luxembourg


Postby BurningSheep » Jun 14, 2002 @ 12:21pm

heh, I've made so many programming mistakes it would take me all day to come up with only a fraction of them. On the plus-sideI've become a pretty routined debugger by now :)

most recent one I can come up with is an ActionScript I had programmed for work (meh, it's not even a real programming language ;)). ne ways another programmer made some minor changes to it, and it mysteriously stopped working. It was a game and it wouldn't save the scores anymore. After 5 hours of debugging i was literally banging my head against the wall. So I decided to rtfm, and it just said "you can't write to files anymore, if you want to... you're pretty much screwed"
So instead of publishing it with FlashMX, I published it in Flash5 (in which I had written it originally) and everything was working fine.
Do you want custom Snails levels? Click
User avatar
BurningSheep
pm Insider
 
Posts: 1226
Joined: Apr 12, 2002 @ 11:49pm
Location: The Netherlands


Postby accolon » Jun 14, 2002 @ 1:07pm

<div align="center">
<b>while (!asleep()) sheep++;
</b></div>
User avatar
accolon
pm Member
 
Posts: 628
Joined: Jan 20, 2002 @ 10:25pm
Location: Germany


Postby gamefreaks » Jun 14, 2002 @ 9:06pm

Fencepost error...

Or maybe it was when I was first playing around with HPC Quake and I was trying to inialise GameX. In the documentation it said:

GameX gx = new GameX;

I assumed he forgotten the comment and I thought it should have said:

GameX gx; //new GameX

So I couldn't figure out why I was getting crashes...
Doohhhhh!!!!
What if everything is an illusion and nothing exists? In that case, I definitely overpaid for my carpet. -Woody Allen
User avatar
gamefreaks
pm Insider
 
Posts: 466
Joined: Oct 20, 2001 @ 8:52pm
Location: Leicester, England


Postby esw » Jun 15, 2002 @ 12:10am

esw
pm Member
 
Posts: 536
Joined: Jun 15, 2001 @ 5:57pm


Postby Michael Y » Jun 15, 2002 @ 2:23am

User avatar
Michael Y
pm Insider
 
Posts: 1956
Joined: Feb 24, 2002 @ 2:27am


Next

Return to Windows Mobile


Sort


Forum Description

A discussion forum for mobile device developers on the Windows Mobile platform. Any platform specific topics are welcome.

Moderators:

Dan East, sponge, Digby, David Horn, Kevin Gelso, RICoder

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

cron