BreakPoint

cancel
Showing results for 
Search instead for 
Did you mean: 

Rube Goldberg Code

Just saw (and fixing(?) ) code recently which is not as big as tst's example, maybe half the size...  Full of stacked sequence structures...

--- sigh ---  but that's not so bad...

--- sigh --- 😞

it is FULL of Local variables.  Each and every value on practically every wire is connected to a Local Variable.  Either read or write.

Also saw something that intregued me and I was impressed for a moment until I realized what it meant..

A cluster whose input cluster is a local... I'll show an example (not from the code)...  needless to say my arms dropped when I realized what it meant.  All clusters are in this fashion.

My example is not quite right...  you'd have to replace the indicator with a Local Variable.  All terminals (ctrl or indicator) are located in one frame not connected to anything.

It's the second time I encouter such style..  The authors are from different cities... Many miles apart..  Same style..  interesting... 😮



Message Edited by JoeLabView on 02-05-2008 08:24 PM
0 Kudos
Message 131 of 2,600
(13,483 Views)

Hi Ray,

I would guess the author of that code does not know about typedefs so using that code constructs allow them to change the cluster def without breaking the code. Let me go onto guess that app does not have many or any sub-VI's.

RE: tst "Scary"

We have taken over a number applications that were orignally developed by other LV shops. One of them has been in developemnt for about 11 years and looks very similar. We have been cleaning the code up one VI at a time. The funny part about code like that is that as I wonder around the cubicle farm and peak at the code others are developing, the first thing of their mouth is;

"I did NOT write this!" Smiley Surprised

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 132 of 2,600
(13,462 Views)

Ben,

I wish you were right!  😮

There are 205 sub-vi's all abusing Local Variables extensively..

I'd get in trouble if I showed you the code..  But imagine sub-vi's having 5 layers of Stacked Sequence Structures..  Every layer passing data via Locals.

Average number of Locals PER terminal is 25.

(is it ok to cry?)

0 Kudos
Message 133 of 2,600
(13,443 Views)

JoeLV,

It might look bad for someone with solid colors to cry.  I found some of CC's friends to do the job for you. 

 

 

Message 134 of 2,600
(13,407 Views)

Ok, educate me.  What makes this a bad style exactly?  I've used this kind of construct and don't (yet) see a good reason to abandon
them.  Am I missing something that should be obvious?  Let me describe how I view it:
 
1. Not a race condition.  The bundle-by-name node requires the local to be read to act as an input before the output is produced.
 
2. Not merely writing a value back to itself.  At least some of the cluster elements are being updated, maybe all of them.
 
3. (Can be) much less diagram clutter to use a Read local rather than a diagram cluster constant, especially for very large and complex
clusters.  The tradeoff is the possibility of an extra copy of the cluster when using local variables.  (If I need to do this kind of thing many
times, I'll make a function which simply returns a default cluster constant, and wire that function into bundle-by-name rather than using
a constant or a Read local).
 
4. Even though I personally almost never use clusters without typedef'ing them, this kind of construct helps ensure type-matching for
non-typedef'ed clusters.  Using a diagram constant could allow them to get out of sync.
 
-Kevin P.
ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
Message 135 of 2,600
(13,399 Views)