BreakPoint

cancel
Showing results for 
Search instead for 
Did you mean: 

Why some people say Local Variables are bad...


Broken Arrow wrote:

Spaghetti with local balls.


All the terminals are disconnected and nicely lined up in the upper right of the diagram. Clearly a text programmer. 😄

 

Further down on the diagram, he's hammering 34 individual property nodes with every iteration of the while loop, no matter if the values change or not. The only difference between the two cases is the value of a single diagram constant (I don't know why we need 7 instances of each constant!). Why duplicate everything?

 

 

 

 

Message Edited by altenbach on 12-19-2009 11:08 AM
Message 141 of 396
(8,827 Views)

Seen here.

 

I like local variables.jpg

Message 142 of 396
(8,781 Views)

JB wrote:

Seen here.


Where exactly??? 😮

0 Kudos
Message 143 of 396
(8,774 Views)

JB wrote:

Seen here.

 

I like local variables.jpg


 

Nice picture, bad link.
Richard






0 Kudos
Message 144 of 396
(8,761 Views)

altenbach wrote:

JB wrote:

Seen here.


Where exactly??? 😮


Based on the link we should ask JB's friend for the correct link. Smiley Very Happy

Message 145 of 396
(8,739 Views)

smercurio_fc a écrit:

altenbach wrote:

JB wrote:

Seen here.


Where exactly??? 😮


Based on the link we should ask JB's friend for the correct link. Smiley Very Happy


 

Unfortunately this friend is already on holidays ! LOL

Sorry for the wrong link. Here is the right one

0 Kudos
Message 146 of 396
(8,728 Views)

Another one of those misconceptions that sees a need to write to a terminal and its local variable

at the same time while reading the same local nearby also, either slightly before or after it gets updated. 🙂

 

Clearly a text programmer 😄

 

 

 

Of course to top it all off, there are sequence frames with no functionality or purpose

and the while loops burn through CPU like its unlimited.  

 

(spotted here)

 

 

Message Edited by altenbach on 01-20-2010 11:28 AM
Message 147 of 396
(8,520 Views)

This is when Shift Registers are more useful than Locals...

 

maybe if Local Variables were harder to find within the palettes..

 

found here:

http://forums.ni.com/ni/board/message?board.id=170&thread.id=469608

 

 

Message Edited by Ray.R on 01-21-2010 12:35 PM
Message 148 of 396
(8,475 Views)

Here's one I responded to just today.

 

Note the sheer number of "Wheel circumference" locals, all hanging out together in the same loop.  The indicator is located outside the loop...maybe its value is calculated before the loop starts, and maybe it isn't, there's no data dependency. 

 

why do we need 5 of them.PNG

 

And might the "Encoder 1 count" local variable be causing a race condition?  Hmmm, are we using the previous calculation...or the current one....? 

 

From the same code....

 

why not just use the control.PNG

 

Ah yes, the joy of having a control sitting out there, wired to nothing, with a local variable right next to it!  Maybe we could just wire the value in directly from the control, eh?

 

Maybe?

Message 149 of 396
(8,378 Views)

Good catch Diane.  I can only imagine what the rest of the code looks like.

The bigger question is: where do you start debugging such code?  😉

0 Kudos
Message 150 of 396
(8,348 Views)