Some idiot's been messing with my code...

Miscellaneous Forums/General Discussion/Some idiot's been messing with my code...

...Me! :P

Have you ever tracked a bug down in your code, or just realized a way you're doing something is flawed/naff, and sworn at yourself out loud? It's like someone else has been messing with my code. "What the @#!* is that?", I hear myself exclaim on occasions. Or, "Jesus, I must have been on drugs when I did that!".

Anyone else suffer this, or am I just nuts? :P

I'm my own harshest critic, I think is my problem...

There's a saying: "You are your worst critic."

And yes, I've had this happen. Frankly, I call myself various undescribable horrors each time.

I always blame it on the evil little code elves that come in while you are sleeping and mess up your code.

The worst bugs are the worst to catch.

There's 1 very nice one in my bug-history however ^_^

I made some video-editor which loads seperate images from a dir.. in the editor you could place them on a timeline, whichever image on whichever timeline-position.

I always tested with a few hundred frames while programming it.. I figured it worked.

Then I began my first big test.. several thousand images in a dir. Yet, the loader only loaded about 500 of them! I tried everything, made all kinda alphabet-sorting, you name-it.. somehow I didn't understand why only about 500 files were loaded.

So, what was it?

After each individual file, I forgot to close the filestream :P So each new load-operation opened a new ADDITIONAL stream.. and aparentally Blitz(+) has a limit of streams, prolly about 512'ish.. :)

This is the most insane bug I've ever made, you can hunt this one forever if you assume from the first few hundred files) that the routine actually works!

Looking back on it, it was clean rubish ofcourse, I always close such streams. :P

Glad it's not just me, then. That's what I try and blame it on too, Brice. Those little b@#*ards! :)

I do it everyday, you spend 30 mins chasing a bug only to go "Oh, you twat!"

I make the same two errors repeatedly:

The miss-type
As anyone who's read my posts (and their numerous spelling errors) over the time i've been visiting here may have summised I have terrible trouble with the lack of strict variable names in Blitz3D.

The perfect function
I write out big chunks of code at once, a whole new "piece" to plug into the game which I then test. In effect, I complete the first draft and then see if it works. The most often result is that it is "probably" absolutely perfect but I dont realise it.

My problem is the moment I complete a new section of the program I test it and, all too frequently, wonder why it doesnt work at all - let alone work badly.

I then start tinkering with the function, and all the while the problem is actually that i'm not even calling it.

I then start tinkering with the function, and all the while the problem is actually that i'm not even calling it.
lol. Classic! :)


I then start tinkering with the function, and all the while the problem is actually that i'm not even calling it.


Ooh... been there, done that.

Missing out the underscore in an important global variable> it looks the way it should do, so you skip over it :o(

Been there on both points Becky. I hate the lack of strict vars in Blitz PLus, I've waster HOURS, maybe even DAYS on that one. I use Protean now and declare them mixed case and type them in lower case and the IDE autocorrects the case, if it doesn't I know they're typed wrong!

I then start tinkering with the function, and all the while the problem is actually that i'm not even calling it.


Wow! I mean WOW!!!! I have done this sooooo many times as well!

That would be my number one "WTF?"

My other big one is when copying variables and pasting them in all the locations where I am using them, I find that I didn't copy the var in it's entirety.

So I go and highlite "ThisVariable"
and paste it in 10 other locations like a machine (call me macro boy, down, home, ctrl-V, down, home, ctrl-v, etc).

So the next 10 uses are "hisVariable"

ARGGGGGGGGG

"Oh you twat" is a favourite of mine!

Messing with a function not being called, yeah yeah... been there...

Messing with a function thinking it's another function and wondering why it's not fixing the bug but doing stuff that is totally unrelated... but actually it is related because you're messing with the wrong function... if you get what I mean!

or am I just nuts? :P

I think so. Another 0.00003 tonnes of CO2 produced I'm afraid.

Uh?

What I meant was that it was rather pointelss don't you think? I mean did anyone benefit from your topic? Did anyone learn anything at all from it?

These silly topics really are pointless and as a result it is wasted energy and another 0.00003 tonnes of CO2 is produced for absolutely no benefit at all.

These silly topics really are pointless and as a result it is wasted energy and another 0.00003 tonnes of CO2 is produced for absolutely no benefit at all.
I bet you're real fun at parties...

+BlackD

I'm just reaching the staged where i don't remember writing parts of my code any more. My comments are actually becoming important.

Chill, Winston. Not everything in life has to have a point. ;)

sometimes i confuse "m" with "n". that's the worst bug possible.

"Candy doesn't have to have a point. That's why it's candy."

This post is the sort of candy that someone licks until it's really sticky, and then somehow it gets stuck to someone else, and then someone else again... thus binding the community together as a cohesive whole through our shared experiences of being stuck together by licked candy. Or something.

Or it was, until Mike Teavee turned up.

Messing with a function thinking it's another function and wondering why it's not fixing the bug but doing stuff that is totally unrelated... but actually it is related because you're messing with the wrong function... if you get what I mean!
Ooooh, been there, more than once I'm afraid....

lol @ LineOf7s
lol @ GA
lol @ BR
lol @ big10p
lol @ DH
lol @ Rob Farley
boo hiss, <raspberry> @ Prof

In point of fact, Prof, some people might pick up on some coding technique tips from this that prevent bugs in the future - thus letting them Shutdown at 2a.m. rather than bug-hunting until 6a.m. with all the attendant light-burning, house-heating and PC-fuelling that goes with it.

I alternate between Cut'n'Paste+BadlyEdit hack jobs that see things like
MonsterPosition\x_ord = .....
MonsterPosition\y_ord = .....
MonsterPosition\x_ord = .....
then wondering why the Monster moves in and out of the screen in a weird way that seems to be linked to its sideways movement...

... and having blatantly obvious variable names like TotalMonsters that somehow end up being written as MonsterTotal during a quick bit of hacking. I'm sure If I stuck to Frank Taylor's naming convention or similar I could eradicate this kind of thing... But life would be less fun I guess.

yeah 10p... i've done the same thing... expletives and all :)


--Mike

My most common is now using the Blitz+ keycode numbers in place of the BlitzMAX ones. Thus not being able to close the program with escape and getting stressed trying to find whats stopping KeyHit from working. Although thats getting less common now.

My best one was when i had a function reading all the contents from a folder into a listbox in Blitz+ and not realising that folders had . and .. in. I originally thought the computer was just being slow so i went and watched a half hour of TV only to find it still working away. And as I didn't know . and .. even existed i ended up spending a few days on it before i posted on the forums and was told about the . and ...

BJumper: "TotalMonsters that somehow end up being written as MonsterTotal" This gets me too, if only the compiler was strict!

MattVonFat: haha never used DOS then?

MattVonFat: haha never used DOS then?


Only when I formatted the hard drive. But I decided not to use it again when my dad told me off for it. I don't know why he got so angry, I was young (well younger than i am now) and all young people experiment with things - he should be glad it was destructive DOS commands rather than drugs or alcohol :)

format liver: /alcohol
format brain: /crack

... and having blatantly obvious variable names like TotalMonsters that somehow end up being written as MonsterTotal during a quick bit of hacking.
Arg! I keep getting caught by that one, too - despite spending ages sometimes thinking of the best name to give a variable/function/constant etc.

Another embarrassing one: I knock out a quick test prog using CreateSphere. I run it. "Uh? Where's the bloody sphere?". I fiddle with the camera position - still no sphere... then I put the Flip in the main loop. "Ooops!". :P

I just found out an idiot was messing with my code too, I was wondering why it would get stuck in a loop like:

for X=-1 to 1
for X=-1 to 1
next
next

Wheres Y?!!?!

hahahaa.... so many hours... wasted...

In delphi I keep looping through tables to read data and a common mistake is this:

While not TheTable.EOF do
begin
read some data
end;

It gets stuck in an infinite loop because I forgot TheTable.Next inside the begin end!

I quite often try to code a full structure before adding the contents so when I do the while loop above, I put the Next in before writing all the read code. Same if I declare a new type variable (or sound/image) in blitz, I like to put in the Delete variable straight away before I do the other code just so it isn't forgotten. Also when I write something using brackets I make the set of brackets and then fill out the contents, if I have to add sub brackets, I add them, then the contents, then at the end it works straight away and I don't have to count all the open ones and close them all in the correct places. Of yeah and of course with functions, if/end if, and while/wend it's best to make the structure then fill it, Protean IDE does this for you.

I then start tinkering with the function, and all the while the problem is actually that i'm not even calling it.

Before I started programming, I kept hearing about how typos are the programmers bane, but nobody mentioned this. I don't know about y'all, but remembering to call a function I just wrote is my #1 mistake; typos aren't so bad, mostly because half the time it's a compile-time error.

Closely related is when I don't bother to comment or remove functions I'm no longer using. I'll come back a month later and tear my hair out trying to figure out what that function does, until I eventually realize it doesn't do anything. AARGH!!!

When I look at my code and think "I must have been on drugs", it's probably because I was.

vinylpusher@ you probably try to be funny, but I see it as you try to glorify drugs and that makes it "funny -= 100".

You just lost a level. Back to Anvilmar for you my friend.

I found it funny. Why not do a find replace on "on drugs" with "drunk" and it's suddenly socially acceptable (unless you are a t-total or realise that programming drunk is futile anyway)

jhocking: Thing is *variable* typos in Blitz are really bad as they are just integers with zero value if you haven't declared them, and this isn't detected at compile time!

Yeah, I know, I have been doing this for a while. That's why I said "half the time" and not "always" or even "usually."

sorry dude!

I have gradually moved over to GA's 'manual code-completion' method of writing the shell logic, then filling in the actual gubbins. Hadn't thought to do it with CreateStuff/FreeStuff combinations... will try to do this in future.

Y'see Prof - this thread is invaluable.

I'm too oldskool to change IDE now, but Protean's automatic code-completion on structures sounds good. I know Dreamweaver does this for me on HTML tags but I can't remember which code environment also does {I generally use Borland CBuilder by choice and MSVC when I am forced to.}

Loops are evil, one pal at previous job managed to send thousands of emails to himself... we others wondered why server utilisation was suddenly so high..

well i am perfect so i never have this problem

glad my ideas helped someone! More CO2 burned.

jhocking: Thing is *variable* typos in Blitz are really bad as they are just integers with zero value if you haven't declared them, and this isn't detected at compile time!


...which is why you should always use 'strict' -- that way you won't automagically end up with new variables. Of course it won't help you if you have a typo and end up matching a different existing variable name.

And of course, 'Strict' itself is just an integer with zero value in Blitz3D/BlitzPlus, which is what they were talking about ;]

When I get blitz max, strict is on baby!

When I code... sometimes it doesn't do exactly what I thought it would do; or do what I expect in the same way, simple to puzzle out... My math needs more work! Back to Calc class for me!

I get nervous if I code something moderately complex and it works first time. I feel more confident in the code if I have to tinker with things a bit to get it to work. :)

Do you ever write a massive function, check it really carefully, run it and go "Yes! It works perfectly! ... wait a minute ... sh*t"

I've had things work perfectly first time, only for me to become incredibly paranoid and spend 5 minutes repeatedly restarting the game/app in disbelief.

I get that way even after tinkering with things for a while ;]

Lol at all...

My latest gaff was I allowed users to input speech marks into text fields delimited by speech marks. Took me a while to work it out and when I did the air turned blue.

I get nervous if I code something moderately complex and it works first time.

It's times like that where I just know things will go horribly wrong once somebody else tries to use my program. If things work fine the first time, that usually means I am unconciously avoiding the problem areas, whereas the first user I hand the program to will just as unconciously home in on said problems.

I'm missing the c key on my keyboard, and sometimes when I code, I don't push it down all the way (it takes more force to push it down), and "Function" ends up as "Funtion" and things like that.

jhocking: That's exactly why I get nervous. :P

Wallows: I wish I had a penny for every time I've typed 'retrun' instead of 'return'. :/

Wallows: Do you touch type then as the C key is a bitch imho.

Wait... your code doesn't always work the first time???

What am I doing right???

OK this was inane considering the number of times I have posted asking for help!
Rook

The worst ones are the bugs that you find.. then fix indirectly on accident and either dont remember the specifics of the bug.. or dont remember what you did that could have fixed it.