BreakPoint

cancel
Showing results for 
Search instead for 
Did you mean: 

Rube Goldberg Code

Somedays you hate to look at other peoples vis that are miss-behaving.  but, Like Stock-car races, the crashes are amazing.  --- seen in the wild enjoy

Untitled.png


"Should be" isn't "Is" -Jay
Message 1051 of 2,635
(11,319 Views)

I have seen this before. Why concatenate a bunch of constants instead of using one constant? This is almost acceptable because it uses a special character constant. But still. Seen here.

 

Example_VI_BD.png

=====================
LabVIEW 2012


0 Kudos
Message 1052 of 2,635
(11,222 Views)

@Steve Chandler wrote:

Why concatenate a bunch of constants instead of using one constant?

 


I'm not sure whether to side with this being an issue or not. It is unsightly, and wastes (valuable) whitespace, but gets compiled into the same bit of object code. 

I tend to only make an issue of bad code if it creates Rube Goldberg source AND object code rather than just being bad source code.

_____________________________
- Cheers, Ed
0 Kudos
Message 1053 of 2,635
(11,192 Views)

Steve,

 

- and how do you read something with lots of white space in easily?

Concatenating constants doesn't slow down runnning in the Runtime, but it does often make the block diagram smaller and easier to read, so it could be argued that this is a good thing in a large number of cases.

 

James

CLD; LabVIEW since 8.0, Currently have LabVIEW 2015 SP1, 2018SP1 & 2020 installed
0 Kudos
Message 1054 of 2,635
(11,177 Views)

I like your point, James.

To my opinion, readability of the BD is the top-level concern.  Especially when performance doesn't matter.

Guenter

Message 1055 of 2,635
(11,173 Views)

@Steve Chandler wrote:

I have seen this before. Why concatenate a bunch of constants instead of using one constant? This is almost acceptable because it uses a special character constant. But still. Seen here.

 

Example_VI_BD.png


 

In my case... dyslexia.

 

If my head could easily process sets of characters, I would use the single constant and ... probably would still be a C programmer.

 

There was a thread running yesterday called "DRUCK DPI 610 Drivers" that my head kept saying was "Drunk Driver". If I have trouble reading that title what kind of trouble would you expect I would have looking at that contant?

 

So for me, you will often find the rubed version.

 

And for a practical (you judge if it is practical) I was visiting a customer three weeks ago who asked if I could change the file from tab delimited to comma delimited. Since I used the rubed version and had a single tab contant, it ws a snap to change the file format to comma delimited.

 

So if building constants is a rube, then count me in the Rube-camp.

 

Ben

 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 1056 of 2,635
(11,170 Views)

Sometimes a Rube code does not mean bad code. 

 

I would say the above is a mild Rube because it is a slightly more complicated version.  I would let it go.  But it is good code.  There is nothing wrong with it other than taking white space. 

 

 

Message 1057 of 2,635
(11,159 Views)

@Ben wrote:

[...]
Since I used the rubed version and had a single tab contant, it ws a snap to change the file format to comma delimited.

 

[...]

 

Ben

 



That's a full winner.

Guenter

Message 1058 of 2,635
(11,153 Views)

Wow what a reaction! You are all right - definitely readability is the most important thing. I think someone said that bad object code and bad source code make a Rube Goldberg. I disagree. Code readability is the most important thing as long as the object code works as expected.

 

The example I used was a bad example. I should not have picked on such a benign little piece of code.

 

BUT!!!

 

It reminded me of something that I very recently had to deal with. Below is an actual example (constants changed to protect the guilty) of a de-rubitization that I performed a while back. Notice that in the non-rube I still concatenate two constants.

 

The innocent little piece of code brought back some bad memories.

 

Example_VI_BD.png

=====================
LabVIEW 2012


Message 1059 of 2,635
(11,142 Views)

Ok, Steve.  This one convinces even me.

Message 1060 of 2,635
(11,129 Views)