From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

BreakPoint

cancel
Showing results for 
Search instead for 
Did you mean: 

Rube Goldberg Code

Well I found this little gem a while ago - I can't find the original thread but I remembering it piquing my interest because of the file size of the VI (4MB) and the repeated mention of sequence structures.

 

On opening it, I was presented with 6 tabs with a number of boolean controls on each one.

 

Then I opened the block diagram...and saw this:

 

2015-11-27_10-56-34.png

 

Erm....where is the code? Going through the sequence structures didn't reveal anything and then I scrolled down...

 

2015-11-27_10-58-37.png

 

Every page (there were 6 pages) of the sequence structure was the same. It goes all the way up to DAQ Assistant 136.

 

Some serious rube goldberging going on there with the boolean wired to a case structure, one case having a 1-element array of true and the other having a 1-element array of false wired to a different DAQ assistant for a single channel.

 

I think this would have probably boiled down to a single DAQ assistant!


LabVIEW Champion, CLA, CLED, CTD
(blog)
Message 1681 of 2,571
(11,364 Views)

@Sam_Sharp wrote:

Every page (there were 6 pages) of the sequence structure was the same. It goes all the way up to DAQ Assistant 136.

 


Also note that each frame takes 1000 (!!!) seconds (using the default control values) so the stop button only gets read every ~1.7hours).

 

The extent of the code problem is more easily seen by replacing the stacked with a flat sequence followed by a diagram cleanup.

 

 

Message 1682 of 2,571
(11,339 Views)

Nice to see Diagram cleanup working sometimes. 🙂

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 1683 of 2,571
(11,294 Views)

@Yamaeda wrote:

Nice to see Diagram cleanup working sometimes. 🙂

/Y


If your code is ugly, cleanup does wonders to make it readable for the most part.  If you spent lots of time manually cleaning up your code, nudging wires carefully, then cleanup is not going to make it prettier.

Message 1684 of 2,571
(11,249 Views)

@altenbach wrote:

@Sam_Sharp wrote:

Every paaage (there were 6 pages) of the sequence structure was the same. It goes all the way up to DAQ Assistant 136.

 


Also note that each frame takes 1000 (!!!) seconds (using the default control values) so the stop button only gets read every ~1.7hours).

 

The extent of the code problem is more easily seen by replacing the stacked with a flat sequence followed by a diagram cleanup.

 

 


Ignoring the obvious complaints, my inner perfectionist is outraged that DAQ Assistant instances are no longer sequentially located....must...fight...urge...

 

Edit - if they ever were sequentially located...

---
CLA
0 Kudos
Message 1685 of 2,571
(11,199 Views)

Hooovahh wrote:

If your code is ugly, cleanup does wonders to make it readable for the most part.  


Yes, that's the sometimes i was referring to. 🙂

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 1686 of 2,571
(11,126 Views)

Another example from the "Complex is Simpler" department 😄 (detailed discussion is here)

 

Stock VI from the 3D graph tools needs (top of image):

  • 3x sine function
  • 2x cosine function
  • 5x multiply functions
  • 5x wire branches

15 items!

 

Using complex math the same can be reduced to (bottom image) 😄

  • 2x "Polar to RE/IM" functions
  • 0x wire branches

2 Items!

 

The bottom code is arguably simpler. Note that none of the wires are complex.

 

 

Message 1687 of 2,571
(11,023 Views)

The discussion of poor NI code reminded me of some of the worst code I found that we ship.

 

For an NIWeek project I worked on we needed to let the user generate some sort of waveform so I figured starting off with the code for the Simulate Signal express VI UI would save me a lot of time. I took one look at this and just decided to do it myself. Not exactly Rube Goldberg code but I'm sure if I was actually able to understand it I would be able to find something.

 

<National Instruments>\LabVIEW 2015\vi.lib\express\express input

 

Woa.png

 

Matt J | National Instruments | CLA
Message 1688 of 2,571
(11,006 Views)

There are many ways to remove duplicate rows from a 2D array, but it should not need 3 FOR loops, 2 case structures and 10 primitives, resulting in code that does not even produce the right result. 🙂

 

(seen here)

 

 

 

One possibility is using Variant attributes (bottom), but there are plenty of other simple ways. The best algorithm probably depends on the size(s) of the input.

 

Message 1689 of 2,571
(10,880 Views)

@Jacobson-ni wrote:

The discussion of poor NI code reminded me of some of the worst code I found that we ship.

 

For an NIWeek project I worked on we needed to let the user generate some sort of waveform so I figured starting off with the code for the Simulate Signal express VI UI would save me a lot of time. I took one look at this and just decided to do it myself. Not exactly Rube Goldberg code but I'm sure if I was actually able to understand it I would be able to find something.

 

<National Instruments>\LabVIEW 2015\vi.lib\express\express input

 

Woa.png

 


Have you looked at the TBD Core.vi?  I actually got a personal apology for that.   At least that code fits on one screen, has a logical flow from left to right  and documentation on what the sections do! (Impossible documentation on the TBD Core vi since the "Resize for Localization" P-nodes are scattered everywhere)


"Should be" isn't "Is" -Jay
0 Kudos
Message 1690 of 2,571
(10,799 Views)