Showing results for 
Search instead for 
Did you mean: 
Reply

The Boneheaded Code Thread

Re: The Boneheaded Code Thread

Kudos Ben! That is the spirit I had in mind for this thread. If this were a book a good title might be "Brave Confessions of the Brain Dead Software Engineer"

 

Let's keep 'em coming!

=====================
LabVIEW 2012


0 Kudos
Message 11 of 21 (2,395 Views)
Reply
0 Kudos

Re: The Boneheaded Code Thread

[ Edited ]

OK I'll play too.

Task: Jeff quick set up a vi to cycle a temperature chamber up and down all night with this recording device in the chamber.  We want to make sure these production prototypes do what they are supposed to do (Shut off when either too hot or too cold).  You have 30 Minutes to set up.

 

Here is a simplified recreation.

 

BH.png

 

 

Spoiler
We learned the plastic melts at 137C

 

Spoiler
Spoiler
The AND is bad!!! shouldn't that be an OR?
I've since learned how to use In Range And Coerce

 

 

 

 

 

 

Message 12 of 21 (2,364 Views)

Re: The Boneheaded Code Thread

I must have had a hundred bugs that were due to me reversing the True and False cases, or using Less Than when I should have used Greater Than.  Almost seems like I do it wrong more than 50% of the time.

0 Kudos
Message 13 of 21 (2,349 Views)
Reply
0 Kudos

Re: The Boneheaded Code Thread

Yeah, I've been there Jeff.  My recent boneheaded mistake was checking to see if an element want found in an array (Search 1D Array) and set the comparison to >0.  It took me awhile before I realized that it's >=0.


There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines

The discussions from the Advanced User Track is not over. Join in the conversation: 2016 Advanced Users Track
NI-Week attendees, click here to take the survey for the sessions you have attended!
Message 14 of 21 (2,307 Views)

Re: The Boneheaded Code Thread


drjdpowell wrote:

I must have had a hundred bugs that were due to me reversing the True and False cases, or using Less Than when I should have used Greater Than.  Almost seems like I do it wrong more than 50% of the time.



They're like USB connectors.  50% chance of getting it in the right way the first time, and 80% of the time you get it wrong.

Message 15 of 21 (2,296 Views)
Highlighted

Re: The Boneheaded Code Thread

Odd...I find that if I have a 50% chance of getting it right, I have a 100% chance of getting it wrong.

 

SnowMule is either smarter or luckier than I am.  Smiley Very Happy

Message 16 of 21 (2,286 Views)

Re: The Boneheaded Code Thread

Also, you're not subtracting the step from the previous value, but the previous value from the step? This means on the first attempt to reverse direction you end up with a negative temperature (once you fix the boolean logic error)?

 

subtract.jpg

Thoric (CLA, CLED, CTD and LabVIEW Champion)


0 Kudos
Message 17 of 21 (2,255 Views)
Reply
0 Kudos

Re: The Boneheaded Code Thread


Thoric wrote:

Also, you're not subtracting the step from the previous value, but the previous value from the step? This means on the first attempt to reverse direction you end up with a negative temperature (once you fix the boolean logic error)?

 

subtract.jpg



go figure! recreate a bonehead mistake and make another! Smiley Embarassed

Message 18 of 21 (2,253 Views)

Re: The Boneheaded Code Thread

[ Edited ]

In benckmarking code, why the @#$@#$!#$!#$!#$!#$!#$ won't my two sums come out the same do my two sums SOMETIMES come out the same:headbang:

 

 

 




CLA, LabVIEW Versions 2010-2013



0 Kudos
Message 19 of 21 (2,192 Views)
Reply
0 Kudos

Re: The Boneheaded Code Thread

Just looking at the picture, they will be the same if you have fewer than 256 matches. Smiley Very Happy

Message 20 of 21 (2,183 Views)