LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

indicator control

OK,

Since I just jumped on Christian last week about over-simplifying a rule, its time for me to eat humble pie and clarify my statement.

1) When a value is available in a wire and a control then it is preferable to use the wire, regardless of how long the wire becomes.

2) It is never acceptable to use a set of locals to avoid a long wire*.

Yes I use locals in my code but I keep them to a minimum and are only used to support the GUI when the terminal of the control is already used on the diagram. Extra thought is given to enusre that there is only one writer of the local active at any time.

Ben

* Because they introduce chaos. Smiley Wink

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 31 of 52
(1,471 Views)
Wow... what a can of worms.
 
I like what Scott said.  Local (or any other language syntax) have their use.  Too often they are either misused or completely abused.  Locals are not the solution to all problems.  Locals in themselves are not evil.  Their abuse makes them an obvious source of bad coding.
 
If you want to use Locals, by all means go ahead.  Same goes with listening to advice from others.  Read a thread recently where someone flamed smercurio for his good advice and meanwhile the person was not even reading it.  It's up to anyone in this forum if they want to learn or not.  Myself included.  Why I don't like Locals?  Simple.... I have to clean up the mess..  And what I see is quite horrible indeed.  All Locals... everywhere.  Similar to the example mathan showed in this thread. 
 
Remember one important thing.  Have fun coding..  😉
 
Message 32 of 52
(1,463 Views)


@JeffOverton wrote:
Locals are also a highly efficient way to terminate multiple loops if one loops is in control.




Ah, but then you have to carefully monitor the termination of each loop and then reset the control. You can't use a mechanical "reset when read" option with local variables. For this I prefer the synchronization primitives. Notifiers, queues etc. which all go invalid when one loop terminates and destroys the synchronization reference. Occurrences are another good primitive for this.

LabVIEW ChampionLabVIEW Channel Wires

Message 33 of 52
(1,443 Views)


@JoeLabView wrote:
Wow... what a can of worms.



Or a can of long wires? I have to agree here with Ben's restatement of his thesis. Local variables to get rid of long wires is equivalent to the GOTO statement. I was just looking at our HVAC which was suddenly putting out 114 degF air and our Facilities Engineer was looking at the basic code and realized that he had messed up all the gotos. Even with a lot of code reading experience it was almost impossible to follow that code without diagramming it out.

I've said it before, you can write spaghetti code in any language but in LV it looks like spaghetti!

Also it is not just a style. Some folks have thought long and hard about maintainability, robustness, reliability etc. You can toss that away, but you are wasting yours and others time and money.

But have fun coding. I just got a LV routine from a vendor for review. LOTS of local variables, lots of wires and diagrams that are multiple screens. Don't even get started on the sequences..... You can tell that someone is obviously coming at this from a C background. I did as well, but you can't think of it as just a way to draw C code, that is pushing the square peg in the round hole!

LabVIEW ChampionLabVIEW Channel Wires

Message 34 of 52
(1,441 Views)

Thanks sth for the wise comments 🙂

I didn't see Ben stating an absolute rule.  He & I were just stating that using Local Variables to replace wires is not a good idea.

And we always keep in mind robustness, maintainability, scalability, (and re-use).

Just sharing experiences, not to offend anyone 😉

Message 35 of 52
(1,438 Views)
Ray,

Sorry, I should have given you and Ben credit for the comment about replacing long wires with variables is bad. I totally agreed with that. If you are really good, you can hide the local variables under the icon and make all connections disappear! So you can get the ultimate Obfsucatory LV Code Contest winner! Just a bunch of floating icons with no connection. I suppose an OLVCC would be fun to see how unreadable code can get.

I know that you keep the principles of good coding in mind. It was in response to some other comments in this thread that has gone on for way longer than it probably should. We are as usual trying to provide a little wisdom of experience and having been there, done that, and had to clean up later, we try to make suggestions to help others avoid the wrong paths.

Cheers!

LabVIEW ChampionLabVIEW Channel Wires

Message 36 of 52
(1,435 Views)


Ben wrote:
"If there is nothing evil, how do you that something is good????  "
 
Getting philosophical on us are you?
 
Its easy if you do not look at good as the oposite of evil but rather define good as the absence of evil.
 
Hmmmm? Smiley Wink
 
Ben



Hi Ben,

Your premise is similar to the arguement that Einstein had with his professor regarding theh 'Faith in God'.

- Partha ( CLD until Oct 2027 🙂 )
Message 37 of 52
(1,427 Views)


Pnt wrote:

Two stars Smiley Mad for just saying , locals are not evil ?!

...........................................................




Pnt,

Dont worry; I m with you. Smiley Happy

I gave corrective/compensatory 5stars there & bonus 5 stars here. Smiley Wink

- Partha ( CLD until Oct 2027 🙂 )
Message 38 of 52
(1,427 Views)

Vow,,,, Smiley Happy

Many many many more messages just within few hours. Smiley Tongue Great to see all the discussions from all the pioneers. I agreed all your comments and am honouring you all here.... Smiley Surprised

Anyhow, it seems nowadays some threads which starts with technical discussions leads to some nontech comments Smiley Mad (don't know whether its related to discussion or not) even we have separate boards for that.... Smiley Sad

Thanks,

Mathan

0 Kudos
Message 39 of 52
(1,419 Views)

parthabe and others... thanks

sth wrote: "Local variables have the ability to "Heisenberg" your code. Then you will have to hire a good quantum mechanic like Ben to eliminate the uncertainty. "

Really clever...

0 Kudos
Message 40 of 52
(1,401 Views)