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

I gove kudos for any contribution that has some entertainment factor. 😄

0 Kudos
Message 1111 of 2,571
(11,330 Views)

Maybe to the rarely acknowledged skills of controlled expansion of spaghetti diagrams? It is a lost art, like sailing multimast square-sail ship... As I said, the thing does its multifunction job, but would look very differently if I took the week or two needed to rewrite it nowadays. I just don't have any incentives to do it at this time.

0 Kudos
Message 1112 of 2,571
(11,326 Views)

@James W wrote:

@X. wrote:

 

I have let a piece of code from the late 90's grow beyond fixability and keep posponing its translation into modern LV.

What encourages me to procrastinate is that despite being unwieldy (its diagram won't even fit into my 2M pixel screen) it still does the job and I can still write some quick additions whenever I need a new functionality.

For what it's worth, here is a snapshot of it (actually a scaled down image I got from the "Get Image Scaled" Method):

 

 

It makes abundant use of global and local variables, is full of race conditions, wires zigzag all over the place, you name it.

BTW, there are about 50 cases in the main case structure and a dozen or so other case structures around it (and many more within), each one pretty much testing some UI change (there was no Event Structure at the time). I won't mention how many stacked sequences there is in it...


What were people giving Kudos to here, the admission of a monstrosity, or the admission of fear/laziness when it comes to cutting the beast down to size and improving code quality/documentation?

 

James


What were people giving Kudos to(o) here


Frankly, I belive we have all written vi;s that we are embaressed by.  I helps to improve the community of knowledge that we all occaisionanally shake our heads and say".... Well,   That could have been done better"

 

 

(Look in this thread for JC's greatest fear) 

 

But, I feel, mistakes are the best learning experience... I have only made several and, at my age I cannot afford the time to learn from all the mistakes I can make... Learning from others mistskes seams more urgent these days.    This thread does advertize "mistakes" but MORE!  It points to better practices that help LV'es learn.  I watch this thread on a daily basis......

 

Could you learn more from the mistakes you make?  I cannot!

I can afford the time to learn from the mistakes of others.  I often do enough harn to myself by failing to learn from my own mistakes.

Smiley Very Happy


"Should be" isn't "Is" -Jay
Message 1113 of 2,571
(11,287 Views)

Posted here.

Or is it the quintessential one?

0 Kudos
Message 1114 of 2,571
(11,205 Views)

Found here:  http://forums.ni.com/t5/LabVIEW/Event-structure-with-value-changes/td-p/1937505

 

Original code:

 

 

 

Improved by dkfire:

 

 

Footnote:  Not sure why the original code did not want to convert / create snippet.  Snippet tool does work ok... just not with this one.

Message 1115 of 2,571
(11,144 Views)

It would look even more impressive if you would show the cleaned up version on the same scale. 😄

 

In additions, I would...

  • wire the string directly to the case selector and name the case "Flow"
  • ...

 

(haven't looked at the actual code...)

0 Kudos
Message 1116 of 2,571
(11,132 Views)

dkfire beat me to the solution.  Actually, the solution was not supposed to be posted as we wanted the OP to learn..

 

Although there's still room for improvement, it is a much better code..

 

The scaling was supoosed to be the same..  😮

0 Kudos
Message 1117 of 2,571
(11,112 Views)

Sometimes, express VIs and dynamic data lead to horrible code constructs.

 

In this particular case, each element of the 2D array of dynamic data contains only the information of a single scalar. This thing is 98% packing material. 😄

(Well, the code layout would also not be very reasonable without dynamic data, but that's a different problem ;))

 

 

 

(seen here)

0 Kudos
Message 1118 of 2,571
(11,044 Views)

I thought you stayed away from Express VIs... 😉

0 Kudos
Message 1119 of 2,571
(11,002 Views)

Anyone seen this one yet?

Message 1120 of 2,571
(10,991 Views)