..i'm an idiot.

Joined
Apr 4, 2003
Messages
836
just for fun..

....when was the last time you had one of those "oh, DUH!" moments?

..i had one this evening. i was playing with a microcontroller i bought a while back.... i want to start a small project but figured i better make sure i know how to get code on the board first.

....so i write this C program to blink a light from an output port (and to make it simple, i did it using loops instead of interrupts)... so i spend all last evening searching the internet for a memory map and where the output ports are located... then i spent all tonight trying to get code on the board... i checked every jumper setting. i loaded the stack pointer at several different locations. i tried to put the code in about 10 different spots. i tried relocating the stack pointer to the opposite ends of memory, thinking that maybe the stack grows opposite to what i think it does... then i got to thinking that maybe my numbers were overflowing... and then i almost threw it through the window...


....all that and i realized about 10 minutes ago that i forgot to set the reset vector to the start of my code.

....so after hours of annoyance and hurt pride, my little light blinks happily.
 

tgabe213

2[H]4U
Joined
Aug 27, 2007
Messages
3,684
I spent about 3 hours last night trying to figure out why my vb program wouldn't calculate right. Got to class today and was goin to compare with someone else, and then I realized I was supposed to be dividing by 1 billion and not 1 million. God damn zeros!
 

BillLeeLee

[H]F Junkie
Joined
Jul 2, 2003
Messages
13,486
All of my time wasters are usually the result of wrong capitalization, but the errors I get mask these.

For example, in some struts code, I was putting label values for radio buttons into a .xml file

Code:
<labelvaluelist name="acceptLicense">
        <labelvalue value="true" label="resources.acceptstatement" />
        <labelvalue value="false" label="resources.rejectstatement" />
</labelvaluelist>

When I got errors about it, I originally had labelValueList, so whenever I went to the page, I'd get a System Error. Then I hit the debug mode of the JSP and it says form bean doesn't exist. The whole v vs. V thing was subtle.
 

Mabrito

Supreme [H]ardness
Joined
Dec 24, 2004
Messages
7,004
For its copy and pasting of code. That always get me. When I have those segments of code I can copy to another page, I just run the code thinking it work off the bat and boom it crashes. I look and look at it and then I remember I forgot to change the variables names to match the new variables names on the page. Or if im sending a SQL query to a database, I forget to change the SQL statement to match the new SQL statement. Really stupid I know but that what usually gets me.
 
Joined
Mar 21, 2002
Messages
656
Not me being an idiot, but....

I have spent most of today going through some C# code that a programmer who is "no longer with us" wrote. I have never seen anything so badly thought out, structured or blatently stupid.

To give a prime example:

Code:
string testTrue = "true";
string testFalse = "false";

if ((myBoolean.ToString().ToLower() == testTrue.ToLower()) || (myBoolean.ToString().ToLower() == testFalse.ToLower()))
{
   if (myBoolean.ToString().ToLower() == testTrue)
   {
      string temp = "true";
      bool returnBoolean = Boolean.Parse(temp)
      return returnBoolean;
   }
   else if (myBoolean.ToString().ToLower() == testFalse)
   {
      string temp = "false";
      bool returnBoolean = Boolean.Parse(temp)
      return returnBoolean;
   }
   else
   {
     ...reams of exception handling code...
   }
}
else
{
   ...even more reams of exception handling code...
}

I replaced it all with

Code:
return myBoolean
 

mikeblas

[H]ard|DCer of the Month - May 2006
Joined
Jun 26, 2004
Messages
12,776
When you feel bad about it, just go to The Daily WTF?! and see people who have real problems.

About two weeks ago, I spent all day trying to figure out why some message passing code wasn't working. Turns out I was sending the message to myself. In a million lines of code, I'm the only guy who ever tried to get this server to send itself a message to kick off a job -- we've always, previously, had this server ask some other server to start a job. I spent the day looking at everything else: the job system, my message declarations, and so on ... until it dawned on me that 200 layers away, the message passing stuff was not hooked-up to send-to-self.
 

rgratto2

2[H]4U
Joined
Jul 22, 2005
Messages
2,321
I don't have a good example off hand, but its ALWAYS the little things. Like a typo (capitalization or whatever), or some ridiculous copy and paste problem. The logic errors are of the nature that they're hard to spot because everything seems reasonable at first glance - I hate those!
 

CreganTur

Gawd
Joined
Jan 15, 2004
Messages
882
Mine was today.

I've got some VBA code that makes an API call to GetUserName, to retrieve the name of whoever is using the computer. I'm doing this thorugh Access, so I saved it in its own module.

Well later I try to call the function from a Form, so that a certain textbox will automatically fill with the username, but it kept returning Null values. Drove me crazy until 3 hours later I finally looked at the module code and realized I had it set as a Private Function.

So I deleted the module and moved the function to the Form Code.

Problem solved.
 

maw

Supreme [H]ardness
Joined
Sep 27, 2000
Messages
4,134
Not me being an idiot, but....

I have spent most of today going through some C# code that a programmer who is "no longer with us" wrote. I have never seen anything so badly thought out, structured or blatently stupid.

To give a prime example:

Code:
string testTrue = "true";
string testFalse = "false";

if ((myBoolean.ToString().ToLower() == testTrue.ToLower()) || (myBoolean.ToString().ToLower() == testFalse.ToLower()))
{
   if (myBoolean.ToString().ToLower() == testTrue)
   {
      string temp = "true";
      bool returnBoolean = Boolean.Parse(temp)
      return returnBoolean;
   }
   else if (myBoolean.ToString().ToLower() == testFalse)
   {
      string temp = "false";
      bool returnBoolean = Boolean.Parse(temp)
      return returnBoolean;
   }
   else
   {
     ...reams of exception handling code...
   }
}
else
{
   ...even more reams of exception handling code...
}

I replaced it all with

Code:
return myBoolean

hahah that's funny..

reminds me of the old ASP code that I inherited that was generated using Dreamweaver 3 and 4. Literally hundreds of lines of code to do something as simple as marching through a recordset result.
 

BillLeeLee

[H]F Junkie
Joined
Jul 2, 2003
Messages
13,486
Not me being an idiot, but....

I have spent most of today going through some C# code that a programmer who is "no longer with us" wrote. I have never seen anything so badly thought out, structured or blatently stupid.

To give a prime example:

Code:
string testTrue = "true";
string testFalse = "false";

if ((myBoolean.ToString().ToLower() == testTrue.ToLower()) || (myBoolean.ToString().ToLower() == testFalse.ToLower()))
{
   if (myBoolean.ToString().ToLower() == testTrue)
   {
      string temp = "true";
      bool returnBoolean = Boolean.Parse(temp)
      return returnBoolean;
   }
   else if (myBoolean.ToString().ToLower() == testFalse)
   {
      string temp = "false";
      bool returnBoolean = Boolean.Parse(temp)
      return returnBoolean;
   }
   else
   {
     ...reams of exception handling code...
   }
}
else
{
   ...even more reams of exception handling code...
}

I replaced it all with

Code:
return myBoolean

I had to stop myself from laughing loudly. Maybe that guy was trying to get some job security on the basis of stupidly long code. :p
 

onetwenty8k

2[H]4U
Joined
Nov 24, 2006
Messages
2,554
Not me being an idiot, but....

I have spent most of today going through some C# code that a programmer who is "no longer with us" wrote. I have never seen anything so badly thought out, structured or blatently stupid.

To give a prime example:

Code:
string testTrue = "true";
string testFalse = "false";

if ((myBoolean.ToString().ToLower() == testTrue.ToLower()) || (myBoolean.ToString().ToLower() == testFalse.ToLower()))
{
   if (myBoolean.ToString().ToLower() == testTrue)
   {
      string temp = "true";
      bool returnBoolean = Boolean.Parse(temp)
      return returnBoolean;
   }
   else if (myBoolean.ToString().ToLower() == testFalse)
   {
      string temp = "false";
      bool returnBoolean = Boolean.Parse(temp)
      return returnBoolean;
   }
   else
   {
     ...reams of exception handling code...
   }
}
else
{
   ...even more reams of exception handling code...
}

I replaced it all with

Code:
return myBoolean

That is absolutely amazing.
 

der_jackal

Limp Gawd
Joined
Aug 11, 2006
Messages
412
*abstracted from my blog*

I've been testing a UMDF / KMDF hybrid driver I created as individual elements, just to get some error path coverage because I'm weird like that. That means I was installing the KMDF driver on its own and running unit tests against it, then I was installing the UMDF driver on its own and running unit test against that.

To do that I had commented out some device initialization elements in the UMDF object. Primarily the SetFilter(); property. Not setting that property tells the framework to handle a CreateFile(); request with out sending it down to any subsequent kernel driver...not so good when your KMDF object is a function driver.

This caused a little consternation on my part when I put the two drivers together for the last rounds of testing. All my request submissions from the UMDF to the KMDF driver were being bounced back by the framework with an "invalid handle" error message. I spent a fair bit of time digging for answers on this problem; some fun debugging, some R rated tirades and such, only to have somebody point out the obvious in the end. "Did you set the SetFilter(); property?"
 

halogen

n00b
Joined
Apr 15, 2005
Messages
31
Spent a day trying to figure out why a custom component wasn't displaying correctly in a JScrollPane (Java) rewrote it about five times before I finally went back to the docs and found a setScrollMode method. Worked perfectly after that.
 

GushpinBob

2[H]4U
Joined
Dec 11, 2007
Messages
2,721
I remember making some text based game in C about a year ago for an introductory programming class at the university. After it was graded, my TA told me that I should have used pointers instead of global variables for the score and health points. D'oh!

Not me being an idiot, but....

I have spent most of today going through some C# code that a programmer who is "no longer with us" wrote. I have never seen anything so badly thought out, structured or blatently stupid.

To give a prime example:

Code:
string testTrue = "true";
string testFalse = "false";

if ((myBoolean.ToString().ToLower() == testTrue.ToLower()) || (myBoolean.ToString().ToLower() == testFalse.ToLower()))
{
   if (myBoolean.ToString().ToLower() == testTrue)
   {
      string temp = "true";
      bool returnBoolean = Boolean.Parse(temp)
      return returnBoolean;
   }
   else if (myBoolean.ToString().ToLower() == testFalse)
   {
      string temp = "false";
      bool returnBoolean = Boolean.Parse(temp)
      return returnBoolean;
   }
   else
   {
     ...reams of exception handling code...
   }
}
else
{
   ...even more reams of exception handling code...
}

I replaced it all with

Code:
return myBoolean

I'm sorry that I don't know squat about C#, but what the hell was the guy trying to accomplish?
 

BillLeeLee

[H]F Junkie
Joined
Jul 2, 2003
Messages
13,486
I remember making some text based game in C about a year ago for an introductory programming class at the university. After it was graded, my TA told me that I should have used pointers instead of global variables for the score and health points. D'oh!



I'm sorry that I don't know squat about C#, but what the hell was the guy trying to accomplish?

He just made an incredibly complex way of returning a bool variable. He determined if the bool variable was either true or false by converting the value of the bool to a string, and if it was either, then return it, otherwise, throw exceptions or whatever. I love how he even compared 'true' or 'false' to the strings 'true' or 'false.'

Note: bools can only be 'true' or 'false' (well, and null).
 

mikeblas

[H]ard|DCer of the Month - May 2006
Joined
Jun 26, 2004
Messages
12,776
Note: bools can only be 'true' or 'false' (well, and null).
"bool" can't be null; it's a value type. Of course, we don't know what type "myBoolean" was declared to be -- maybe it ain't "bool".
 

amromousa

Gawd
Joined
Nov 6, 2005
Messages
614
Not me being an idiot, but....

I have spent most of today going through some C# code that a programmer who is "no longer with us" wrote. I have never seen anything so badly thought out, structured or blatently stupid.

To give a prime example:

Code:
string testTrue = "true";
string testFalse = "false";

if ((myBoolean.ToString().ToLower() == testTrue.ToLower()) || (myBoolean.ToString().ToLower() == testFalse.ToLower()))
{
   if (myBoolean.ToString().ToLower() == testTrue)
   {
      string temp = "true";
      bool returnBoolean = Boolean.Parse(temp)
      return returnBoolean;
   }
   else if (myBoolean.ToString().ToLower() == testFalse)
   {
      string temp = "false";
      bool returnBoolean = Boolean.Parse(temp)
      return returnBoolean;
   }
   else
   {
     ...reams of exception handling code...
   }
}
else
{
   ...even more reams of exception handling code...
}

I replaced it all with

Code:
return myBoolean

wow.
 

BillLeeLee

[H]F Junkie
Joined
Jul 2, 2003
Messages
13,486
"bool" can't be null; it's a value type. Of course, we don't know what type "myBoolean" was declared to be -- maybe it ain't "bool".

I haven't done much in C#, but I thought bool was a nullable type?

edit: After some looking, I see that it's 'bool?', not 'bool', that is nullable.
 

Mr.Rogers

n00b
Joined
Feb 6, 2008
Messages
18
Not me being an idiot, but....

I have spent most of today going through some C# code that a programmer who is "no longer with us" wrote. I have never seen anything so badly thought out, structured or blatently stupid.

To give a prime example:

Code:
string testTrue = "true";
string testFalse = "false";

if ((myBoolean.ToString().ToLower() == testTrue.ToLower()) || (myBoolean.ToString().ToLower() == testFalse.ToLower()))
{
   if (myBoolean.ToString().ToLower() == testTrue)
   {
      string temp = "true";
      bool returnBoolean = Boolean.Parse(temp)
      return returnBoolean;
   }
   else if (myBoolean.ToString().ToLower() == testFalse)
   {
      string temp = "false";
      bool returnBoolean = Boolean.Parse(temp)
      return returnBoolean;
   }
   else
   {
     ...reams of exception handling code...
   }
}
else
{
   ...even more reams of exception handling code...
}

I replaced it all with

Code:
return myBoolean

Wow i was sitting in a computer lab with tons of other people around trying to write code and i busted out laughing.
 

riot8ap

Supreme [H]ardness
Joined
Feb 17, 2003
Messages
5,509
Not me being an idiot, but....

I have spent most of today going through some C# code that a programmer who is "no longer with us" wrote. I have never seen anything so badly thought out, structured or blatently stupid.

To give a prime example:

Code:
string testTrue = "true";
string testFalse = "false";

if ((myBoolean.ToString().ToLower() == testTrue.ToLower()) || (myBoolean.ToString().ToLower() == testFalse.ToLower()))
{
   if (myBoolean.ToString().ToLower() == testTrue)
   {
      string temp = "true";
      bool returnBoolean = Boolean.Parse(temp)
      return returnBoolean;
   }
   else if (myBoolean.ToString().ToLower() == testFalse)
   {
      string temp = "false";
      bool returnBoolean = Boolean.Parse(temp)
      return returnBoolean;
   }
   else
   {
     ...reams of exception handling code...
   }
}
else
{
   ...even more reams of exception handling code...
}

I replaced it all with

Code:
return myBoolean

That guy was writing code "Rube Goldberg" style it would seem.
 

CodeX

2[H]4U
Joined
Mar 21, 2006
Messages
2,879
I did something stupid the other day at work...

My boss asked me to put a timeout in our SPI (serial peripheral interface) transfer code because we were having problems with our dataflash chips failing.... so what do I do? Why I use the onboard RTC chip of course... you know, the one that requires the USE of that exact same SPI function to communicate with the processor... Basically I had set up an infinite recursive loop where the RTC read function to get the current time used the SPI transmit function, which in turn tried to (again) get the current time with the RTC read function to handle the timeout....

Luckily I realized it before anyone else saw it lol.
 

Xilikon

[H]ard|DCer of the Year 2008
Joined
Oct 12, 2004
Messages
14,941
LOL, what a big waste of time... I bet he is a very inefficient programmer :rolleyes:

 
Joined
Mar 21, 2002
Messages
656
hahah that's funny..

reminds me of the old ASP code that I inherited that was generated using Dreamweaver 3 and 4. Literally hundreds of lines of code to do something as simple as marching through a recordset result.

You should have seen some of his other pearls of programming wisdom, what I posted was just IMHO the pinacle of his achievements :D

I had to stop myself from laughing loudly. Maybe that guy was trying to get some job security on the basis of stupidly long code. :p

Didn't server him very well, his was turfed out as soon as I did a code review. He was a really good guy, good laugh great personality, but one of the worse coders I have ever encountered. I really need to convince our "non technical" recruiters that they really need a tech on the interviews.

He just made an incredibly complex way of returning a bool variable. He determined if the bool variable was either true or false by converting the value of the bool to a string, and if it was either, then return it, otherwise, throw exceptions or whatever. I love how he even compared 'true' or 'false' to the strings 'true' or 'false.'

Note: bools can only be 'true' or 'false' (well, and null).

"bool" can't be null; it's a value type. Of course, we don't know what type "myBoolean" was declared to be -- maybe it ain't "bool".

It was a standard c# non nullable bool he was working with, so it could have only been true or false. If, and it is a big if, he had been working with bool? then maybe I would have been more forgiving.... actually no, I would have still turfed him out.
 
Top