Showing results for 
Search instead for 
Did you mean: 
Reply

The Boneheaded Code Thread

The Boneheaded Code Thread

[ Edited ]

Sometimes there is a very clear cause to a problem but it is so obvious that I just don't see it. Sort of like looking all over the place for your glasses when they are on top of your head.

 

Let's put our boneheaded mistakes in this thread. Don't give away the problem and let others report how long it took to spot the issue with a fresh pair of eyes.

 

I have a large project with many classes and many queues. I spent an hour trying to debug an "issue" where one of my loops would keep iterating after a dequeue operation. I tried to find what was enqueuing to it by running the Desktop Execution Trace Toolkit. The strangest thing - DETT reported a single enqueue yet the loop kept initializing my device over and over again. I closed LabVIEW and rebooted. Same problem. I was just about to file a bug report (could it have to do with the large number of queues in my application?) when I spotted the problem.

 

How long does it take you to see the problem in this example which demonstrates the nature of the problem? It took me an hour - Doh! Smiley Very Happy And my application has dozens of queues so it's not like I don't know how to use them.

 Doh!_BD.png

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


Message 1 of 21 (3,144 Views)

Re: The Boneheaded Code Thread

Dequeue Element should be placed inside of while loop (I mean second loop). Isn't?

Message 2 of 21 (3,141 Views)

Re: The Boneheaded Code Thread

Smiley Embarassed Yup. And I'll bet it just jumped right out at you too. What's the LabVIEW word for typo?

 

This one got me a long time ago.

 

Example_VI_BD.png

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


0 Kudos
Message 3 of 21 (3,138 Views)
Reply
0 Kudos

Re: The Boneheaded Code Thread

The dequeue and the fact that you're sending "Init" instead of "Initialize" as a command string.....

Message 4 of 21 (3,125 Views)

Re: The Boneheaded Code Thread


Steve Chandler wrote:

How long does it take you to see the problem in this example which demonstrates the nature of the problem? 

 



15 seconds.  But knowing the problem is obvious means you look for the obvious.  I spent a large amount of time on a bug that was staring at me just recently.  I had a polymorphic VI that I removed one instance from, and LabVIEW automatically substituted another instance with the same connector pattern.  Obviously different icon, but I stared and stared at it and didn't notice.  The original VI was "Wait till this actor (loop) receives the shutdown message" and the replacement was "Send this actor the shutdowm message", which has a rather different effect.  I spent over an hour trying to track down who was sending the shutdown message to my actor before noticing.

Message 5 of 21 (3,116 Views)

Re: The Boneheaded Code Thread

I have to admit. it took me longer to swap between full and mobile than to spot the loop invariant init.
Message 6 of 21 (3,095 Views)

Re: The Boneheaded Code Thread

[ Edited ]

Intaris wrote:

The dequeue and the fact that you're sending "Init" instead of "Initialize" as a command string.....


How ironic. I whipped up an example to show my "loop invariant init" and the example had another.... what's the word for typo in LabVIEW... Smiley Frustrated (Although in this case it is in fact just a typo)

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


0 Kudos
Message 7 of 21 (3,079 Views)
Reply
0 Kudos

Re: The Boneheaded Code Thread


Steve Chandler wrote:

Intaris wrote:

The dequeue and the fact that you're sending "Init" instead of "Initialize" as a command string.....


How ironic. I whipped up an example to show my "loop invariant init" and the example had another.... what's the word for typo in LabVIEW... Smiley Frustrated (Although in this case it is in fact just a typo)


I had just assumed that was one of your space-saving strings---- go with thatSmiley Wink  That's your story- stick to it

0 Kudos
Message 8 of 21 (3,052 Views)
Reply
0 Kudos

Re: The Boneheaded Code Thread

I wanted to come back and thatnk you for posting this.  I was a great opportunity to show around the shop!  EVERYONE now has show constant folding of wires ON, they know what the squiggly wires mean and they realize how useful that info can be.

Aside- I've had those squiggly lines on for so long that I usually know which wires will squiggle as I sling them- so when I look at other code ("Hey! Jeff! What's going on with my code?")  It looks funny without the constant wires squggled.  Guess what would have saved you an hour?

Message 9 of 21 (3,036 Views)

Re: The Boneheaded Code Thread

Oh boy!

 

A thread comparing boneheaded code developers. I think i can compete in that sandbox.

 

In this thread, Dennis helped me figure out why* I could not increment a control at run-time.

 

 

 

"I got better" since then.

 

Ben

 

*

 

Spoiler

Yes, it was disabled.

 

Message 10 of 21 (2,997 Views)