LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

A question of Easy-to-Read Code vs Doing the Right Thing

Solved!
Go to solution

It has been my practice to not send data through a loop or VI unless the loop or VI modify the data. Although, sending stuff through "looks" better, makes wiring cleaner, and apparently "does no harm".. or does it? What's worse, branching or tunnels? 

 

Long story short, I have to make code that it easily read by novices and non-coders. With that in mind, they'd like B best. I like C (set for Parallelism if possible) but they'd hate it. Which one of these is "best" in terms of data copies, compiler optimization, etc?

 

style q.PNG

0 Kudos
Message 1 of 4
(998 Views)
Solution
Accepted by topic author rds2112

Most likely the compiler will recognize loop invariant code and optimize it out, making sure that data dependencies are not changed.

 

SO: It does not matter.

Message 2 of 4
(994 Views)

@altenbach wrote:

Most likely the compiler will recognize loop invariant code and optimize it out, making sure that data dependencies are not changed.

 

SO: It does not matter.


Thanks, I had a hunch. Apparently things have gotten better since 5.1 😆

0 Kudos
Message 3 of 4
(987 Views)

I would (almost) always choose clarity over efficiency.  I would make exceptions if speed were critical, such as a time requirement - common with high-speed production - or if code clarity made a hugely noticeable lag.  Were I to make a video game, for instance, I would optimize for speed wherever I could...

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 4 of 4
(950 Views)