LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

My approach to local variables....

Solved!
Go to solution

I want to hear some feedback about this approach.

 

I'm creating a relatively big program, and I like to use offscreen indicators / controls as "local variables". 

 

I'm thinking of turning this into a cluster - typedef, called "local variables" which I can then wire into differnet VI's, and it cleans up the code quite a bit (but adds overhead and makes it less obvious what's going on ). 

 

What do you guys/gals think about this approach? 

 

0 Kudos
Message 1 of 40
(3,367 Views)

What are these "variables" used for?

 

In general, using hidden front panel controls just for local variables is a bad habit to get into.  There are likely much better ways, usually depending on your exact application.  Alternatives include User Events, Queues, Notifiers, Data Value References, and Global Variables.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 40
(3,347 Views)

These are copies of data that are used by multiple subVI's. The user has no reason to view them. This has nothing to do with streaming data, or dynamically-determined outcomes (mostly they are static). 

 

Are you saing global variables are a better idea than local? 

 

I think this system exchanges overhead for nice top-level abstraction. (I.e. instead of passing "tab ctrl reference" "Device SN string" ...etc...more params, I can just pass-by-val a single copy of my "local variables" typedef. 

 

 Why is using hidden front panel controls just for local variables a bad habit to get into?

0 Kudos
Message 3 of 40
(3,344 Views)

@LennyBogzy wrote:
I can just pass-by-val a single copy of my "local variables" typedef. 

 

 Why is using hidden front panel controls just for local variables a bad habit to get into?


You are just making a lot of data copies with both of those things.  And the hidden items makes it so that they are only accessible in that VI.  So if you are making the extra copy anyways, might as well make it a global so that the subVIs can just access them directly.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 40
(3,327 Views)

Right, it certainly increases overhead but who cares? Machines have so much ram these days. For more overhead, II have a elegant, minimalist and abstracted, top-levelVI. Globals would spread this across multiple files, i'm weary of that. 

 

As far as only being accessible to that VI maybe that's a good thing? at least this way I get scope control..

0 Kudos
Message 5 of 40
(3,321 Views)

@LennyBogzy wrote:

Right, it certainly increases overhead but who cares? Machines have so much ram these days. For more overhead, II have a elegant, minimalist and abstracted, top-levelVI.


No.  Nothing is elegant or minimalist.  And it certainly isn't abstracted.

 


@LennyBogzy wrote:

. Globals would spread this across multiple files, i'm weary of that. 


And PC's have terabytes of hard drive space these days.  So why would you care about multiple files.

0 Kudos
Message 6 of 40
(3,292 Views)

"No.  Nothing is elegant or minimalist.  And it certainly isn't abstracted."

 

 

What? How do you mean?

 

As I stated, I go from wiring a bunch of stuff into VI"s to wiring a few generic types (a collection of generic typedefs). How is that not the exact definition of abstraction, minimalism, and elegance? 

 

And it's obviously not the number of files from a storage perspective that is undesirable for me, if anything it's the uncontrolled scope issue...  

0 Kudos
Message 7 of 40
(3,277 Views)

You said you need lots of hidden controls and local variables to access them.  That certainly isn't minimalist.

 

And no one on the forums here who have any experience architecting LabVIEW applications believe that local variables are elegant.

 

As for abstraction, I don't know what you think the definition is, but none of this would apply.

0 Kudos
Message 8 of 40
(3,257 Views)

My definition of abstraction is taking something specific, and making it more generic i.e. abstract (think abstract class). That's exactly what this is. (A car is a more  abstract version of honda). 

0 Kudos
Message 9 of 40
(3,255 Views)

But you are not passing generic UI controls.  You are just collecting a bunch of data in unused controls within the VI.

 

If you really want to talk about classes, then I suggest you start thinking in terms of object oriented programming.  Playing with local variables is about as far away from that as you can get.

0 Kudos
Message 10 of 40
(3,247 Views)