• Advertisement
Sign in to follow this  

PSA: Don't think about programming late at night

This topic is 4592 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I would just like share my stupidity; it is a fine example of why I should stop trying to program late at night or early in the morning too i guess. For the past month, I've been coding a memory manager that will be in my game engine(hopefully). In the garbage collector there is an unsigned int that serves as a counter. It increments by one after each completed garbage collection cycle. It doesn't really matter what I used it for. Well a few nights ago, I thought that everything would be messed up when the counter reaches the maximum value and resets. Thus I began coding away a reaction to that event, but today I started thinking about it some more and I did a little math to figure out that the code I wrote is pointless. At best the garbage collection cycle is completed once per frame though it reality it won't be even close to that rate. So assuming 60 fps. It would take about 828 days or about 2.3 years of continous running to hit the limit and rest. Stupid me Plz feel free to share your personal bonehead moves so I dont feel so bad. [smile]

Share this post


Link to post
Share on other sites
Advertisement
One of my worst bugs involved '#pragma pack(1)'. I had it enabled in the networking module to make message packets as small as possible (I avoid it normally because it slows execution down by messing up alignments). Unfortunately it had become enabled in a few other modules through liberal inclusion of header files. The result being that different parts of the application had different ideas of the sizes of various objects.

It took me half a night of painstaking debugging to figure this out. Objects appeared to be changing between the 'call main.[0040xxxx]' instruction and the 'push ebp' instruction setting up the stack frame right at the start of the called function. In reality the objects weren't changing but were viewed differently by the two different functions. The moral of the story? Include only what you need and be careful when using #pragma pack.

As I progress as I programmer I seem to make fewer bugs and I almost never trip up on things like uninitialised/null pointers anymore but when I do add a bug it usually takes a while for me to find and correct it :\.

Share this post


Link to post
Share on other sites
Quote:
Original post by Azune
The moral of the story? Include only what you need and be careful when using #pragma pack.

Indeed. Best use:

#pragma pack(push)
#pragma pack(1)
... structure definition here ...
#pragma pack(pop)

(that's from memory, and I've only used it about once - check MSDN to make sure those are really the correct pragma pack arguments)

John B

Share this post


Link to post
Share on other sites
Can't remember the specifics, but yeah, I've made some stupid late-night bugs too.

Once, when working on some project at uni, we spent most of the day implementing some feature or other, then some time around 2 am, we looked over our code, discussed that feature we'd spent hours implementing, and we decided that it wasn't actually neccesary. As far as we could see, the special case it was supposed to handle would never actualy occur. Then we deleted it and went home.

Next day, it took us about 3 minutes to realize that it was in fact pretty essential, and then we had to recode it... [lol]

Share this post


Link to post
Share on other sites
The worst part about programming late at night, is when you wake up and realise you haven't programmed anything at all. [tears]

Share this post


Link to post
Share on other sites
Theres a lot of people that program at night. I've done it before but I find it hard to look at the screen when I'm tired so I usually give up.

Share this post


Link to post
Share on other sites
Quote:
Original post by Spoonbender
Can't remember the specifics, but yeah, I've made some stupid late-night bugs too.

Once, when working on some project at uni, we spent most of the day implementing some feature or other, then some time around 2 am, we looked over our code, discussed that feature we'd spent hours implementing, and we decided that it wasn't actually neccesary. As far as we could see, the special case it was supposed to handle would never actualy occur. Then we deleted it and went home.

Next day, it took us about 3 minutes to realize that it was in fact pretty essential, and then we had to recode it... [lol]
Just look on the bright side. The code always comes out nicer the second time you have to write it, because you know what you've learnt from doing it the first time. Just make sure you back it up after that, so you don't lose it a third time!

Share this post


Link to post
Share on other sites
How about...

line 1: programme till 5am (drunk)
line 2: decide to remove all the junk from your system
line 3: empty recycle bin
line 4: defrag hard disk
line 5: GOTO 1

Life sucks

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement