LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Event structure in event structure

Solved!
Go to solution

I strongly disagree.  There can be legitimate reasons for nestiing event structures.

For example, I have a VI that interfaces with a very complicated piece of equipment.  The FP has nested tab controls to organize all the controls & indicators.  Typically a tab page has cluster of controls (sometimes more than one).  To keep the block diagram well organized, an outer event structure captures value change events for the clusters, then within each of those event cases, there's an inner event structure that captures value change events on the individual controls withing the cluster.  This is a good way to structure code that has a very large number of controls.  While it is possible to have a bug that causes a hang, it's easy to find and fix such bugs.

Admonitions and rules that say "always do this" or "never do that" are overly simplistic.  There can be good reasons for making exceptions to guidelines and rules of thumb.  Sometimes people create contorted code for the sole reason of complying with guideline.

"If you weren't supposed to push it, it wouldn't be a button."
Message 11 of 13
(1,117 Views)

@paul_cardinale wrote:

To keep the block diagram well organized, an outer event structure captures value change events for the clusters, then within each of those event cases, there's an inner event structure that captures value change events on the individual controls withing the cluster.  This is a good way to structure code that has a very large number of controls.  While it is possible to have a bug that causes a hang, it's easy to find and fix such bugs.


Well, in this case the inner and outer event are both triggered by the same action, so that's a bit different.

 

Yes, once you know what you are doing, anything is allowed, but I would not recommend for a inexpericed user to stray too far from the guidelines.

 


@paul_cardinale wrote:

While it is possible to have a bug that causes a hang, it's easy to find and fix such bugs.


Easy for you. Hard (or even impossible) for a beginner. 😄

 

Message 12 of 13
(1,111 Views)

@paul_cardinale wrote:

Sometimes people create contorted code for the sole reason of complying with guideline.


Context matters.  "I strongly disagree with you all suggesting a beginner doesn't do something that is likely more contorted for their application because in some cases you can create more contorted code following a guideline."

If we take things in context, that sounds a bit... awkward.  Yes, it's possible guidelines can add more code and make things more messy than another solution.  But, they're in place for a few reasons.

1) They're often cleaner than the code being used otherwise.  In this case, that's certainly true.  In your case, maybe not.

2) They make group work easier.  If people follow the same guidelines, it's easy to pick up a colleague's program and quickly understand the overall design.  It'll take time to understand the details, but that is true regardless.

3) They make it easier to learn.  In this case, you have someone that doesn't really understand the tool they're using.  It's better to teach them a common practice that already solves their problem than it is to make some incredibly convoluted code to maintain the embedded event structures purely on principle.

 

There's a HUGE difference between this post and "can be legitimate reasons."  If you don't see this as a legitimate reason, I'm not sure why you'd disagree to any degree.

0 Kudos
Message 13 of 13
(1,097 Views)