NI Home > Community > NI Discussion Forums

BreakPoint

Showing results for 
Search instead for 
Do you mean 
Reply
Knight of NI
altenbach
Posts: 27,951

Rube Goldberg Code

[ Edited ]
A Rube Goldberg Machine is defined as an "exceedingly complex devices that perform simple tasks in very indirect and convoluted ways"
 
 
One example would the the simplfied pencil sharpener.
 
Let's define Rube Goldberg Code as ""exceedingly complex LabVIEW code that perform simple tasks in very indirect and convoluted ways"
 
For example, let's have a look at the code to test if two booleans are equal. Just beautiful! :smileyhappy:
 
Unfortunately, the beauty of this is lost to most of you. :smileysad: To test this point, I have recently posted an obvious joke to see if anyone actually pays attention.... Apparently not!!! Nobody commented on my example that I snuck into the tic-tac-toe discussion. For comparison, here's my actual code detail compared to the posted image. :smileyvery-happy: Duuhhh!!!
 
 
 
Anyway, I am sure that most of you have some great examples of such code. This thread is the place to share the fun! :smileyhappy:
 
I am not really looking for intentional constructs (anybody can do that!). The focus should be more on existing serious code where you suddenly noticed that there is a much simpler way.
 
(Many code examples posted in the forum contain mini versions, e.g. the use of "delete from array" with "deleted portion" as the only output wired, used as a substutute for "array subset" seems quite popular :smileywink:)

Message Edited by altenbach on 08-03-2006 08:10 AM


LabVIEW Champion . Do more with less code and in less time .

Trusted Enthusiast
Darren
Posts: 2,905

Re: Rube Goldberg Code

[ Edited ]

I'm not making this up...the following was in a VI I was doing a code review on several years ago:

You'll all be happy to know this person no longer works at NI.

-D

Message Edited by Darren on 08-03-2006 01:03 PM

Darren Nattinger, CLA
LabVIEW Artisan and Nugget Penman
Knight of NI
Knight of NI
Ben
Posts: 16,157

Re: Rube Goldberg Code

[ Edited ]

When I was "wee-G-Babe" I wanted to sort folders based their size.

I did not know about the "Cluster Sort" method so I coded up a variation on a bubble sort.

Greg McKaskle said he was stumped for a while but eventually figured it out.

This was one of the first "Bad" from the "Good the Bad and the Ugly" series.

Ben

Message Edited by Ben on 08-03-2006 01:47 PM

Ben Rayner
I am currently active on.. MainStream Preppers
Rayner's Ridge is under construction
Active Participant
jasonhill
Posts: 371

Re: Rube Goldberg Code

[ Edited ]
I am one of those sick bastards that actually enjoys straightening other people's spaggetti.  I have seen some impressive examples of Goldburg constructs.  Recently I ran across the gem in the top illustration.  To the guy's credit, in the original code the selects were nowhere near eachother.  The equality, however, is inexcusable.




Disclaimer: I am guilty of this sort of thing too.  In fact, some examples I have posted have glaring Goldbergs.

Altenbach, you have such an established guru reputation that I am sure many people assumed there was some obscure reason why you set the example up that way.  Especially in the highly optimized enviornment of a coding challenge.

Message Edited by jasonhill on 08-04-2006 10:00 AM

Knight of NI
altenbach
Posts: 27,951

Re: Rube Goldberg Code

I think I saw a variation of this in PRIME.vi posted yesterday. As a bonus, it also contains Darren's construct inside the case structure. :smileywink:

So how do we go about constructive criticism in these cases? I am sure a few nudges in the right direction can make a big difference. Still I am impressed that people with no obvious LabVIEW or general programming background  can get a fully working program together. :smileyhappy:


LabVIEW Champion . Do more with less code and in less time .

Trusted Enthusiast
TCPlomp
Posts: 3,097

Re: Rube Goldberg Code

[ Edited ]
Hi there:

Here is a golberg code about activating a boolean after an enter,

:smileywink: Sorry Altenbach..

Ton

PS which code was faster (first post)?

Message Edited by TonP on 08-04-2006 09:36 PM

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
Active Participant
JeanPierre
Posts: 1,056

Re: Rube Goldberg Code

[ Edited ]
Search for the numerous implementations of exclusive radio buttons (before the native ones)
For example here chutla's implementation and the elegant solution of mine.

Do they still teach how to make truth tables?

Message Edité par JeanPierre le 08-04-2006 07:04 PM



LabVIEW, C'est LabVIEW

Active Participant
JeffB_in_LV
Posts: 451

Re: Rube Goldberg Code

Ok, this is too good to pass up.  I do not mean to offend the original poster(s) but check out the following:

  1. Launch LabVIEW 8.0 (7.1 doesn't allow browsing web examples).
  2. Launch Example Finder.
  3. (You may need to click "Setup", click the Web tab, and increase your number of web hits to 50 or more.)
  4. Include ni.com examples.
  5. Browse into Fundamentals - Arrays and Clusters.
  6. Scroll to the bottom of the list and you'll see a few examples with globe icons and an orange user icon which indicate they were submitted by external users.

Among the 10 or so user-submitted examples in this category are two that are particularly noteworthy.

  • 2D Array to number of Rows and Columns.vi
  • 2D_Array_to_number_of_Rows_and_Columns - revised.vi

Before opening them, think about how you'd write a VI with this name...  For me, I was thinking Array Size followed by Index Array if you wanted them as scalars.  Both of the above VIs are equally effective, but I'm not sure that's how I'd teach someone to do it.  :smileyhappy:  Definitely not too efficient.

Knight of NI
Knight of NI
Ben
Posts: 16,157

Re: Rube Goldberg Code

In this thread

http://forums.ni.com/ni/board/message?board.id=170&message.id=222491&jump=true

I posted a method to copy the contents of a cluster to another cluster.

Ben

Ben Rayner
I am currently active on.. MainStream Preppers
Rayner's Ridge is under construction
Knight of NI
Knight of NI
tst
Posts: 10,923
0 Kudos

Re: Rube Goldberg Code



Ben wrote:

In this thread I posted a method to copy the contents of a cluster to another cluster.


And here I was thinking that this code was supposed to copy an array of variants into the cluster... :smileytongue:

___________________
Try to take over the world!