11-27-2015 05:03 AM
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:
Erm....where is the code? Going through the sequence structures didn't reveal anything and then I scrolled down...
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!
11-27-2015 11:55 AM - edited 11-27-2015 11:55 AM
@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.
11-30-2015 04:03 AM
Nice to see Diagram cleanup working sometimes. 🙂
/Y
11-30-2015 10:56 AM
@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.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
12-01-2015 04:57 AM - edited 12-01-2015 04:57 AM
@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...
12-04-2015 03:27 AM
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. 🙂
12-11-2015 04:01 PM - edited 12-11-2015 04:02 PM
Another example from the "Complex is Simpler" department 😄 (detailed discussion is here)
Stock VI from the 3D graph tools needs (top of image):
15 items!
Using complex math the same can be reduced to (bottom image) 😄
2 Items!
The bottom code is arguably simpler. Note that none of the wires are complex.
12-11-2015 07:13 PM
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
12-16-2015 01:39 PM - edited 12-16-2015 01:39 PM
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. 🙂
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.
12-18-2015 03:53 PM
@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
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)