12-22-2011 08:53 AM
@Steve Chandler wrote:
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.
Aah, well there is bad code and BAD code 😛
12-22-2011 09:15 AM
Good one Steve.
I just wanted to point out that the definition of a Rube Goldberg is something that is (intentionally) implemented in a complicated or superfluous way. I should look up the wiki definition for a clearer description:
"is a deliberately over-engineered or overdone machine that performs a very simple task in a very complex fashion, usually including a chain reaction"
Nowhere in this definition does it mention "bad". So there is good code & bad code. And the is Rube code and optimized code. But there is also good Rube code and bad Rube code. Even the word "bad" needs to be defined.
So I will define "bad" as:
non-working
useless
unreadable
unintentionally overcomplicated that it is not easily readable
unstructured and not meeting recognized standards
obviously undesigned
using Local Variables (I just had to include that one) 😉
and the list goes on based on personal preference...
I'm sure there are plenty of books which describe the difference between good & bad code.
With all that being said, since this is the Rube Goldberg thread, we will surely see good & bad RG's as long as the code is overcomplicated or overdone.
Maybe we should start a "Bad Code Example" thread.
12-22-2011 09:39 AM
You have to love a code construct like the following.
12-22-2011 09:47 AM
@Steve Chandler wrote:
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.
A diagram clan-up on the verbose version would make that very readable.
Messy will always loose out.
Ben
12-22-2011 10:13 AM
@yenknip wrote:
Aah, well there is bad code and BAD code 😛
I am sure Ben and others read that as "bad dog, BAD dog". 😄
12-22-2011 10:24 AM - edited 12-22-2011 10:24 AM
I tried cleanup. It does help a lot but readability is only part of it. It is still hard to add things in the middle. It isn't that hard but I am lazy that way. Also for me it is easier to read code if there are less wires. Don't get me wrong - I like wires! I just don't like when there are too many of them because it makes me dizzy. The original could have at least concatenated the semicolon and linefeed separately and wired the output between each constant in the other concatenate. I still don't like it because there is a wire going to way too many nodes.
Now that I think about it the thing that bothers me about concatenating a bunch of constants is when you have something like a linefeed between each.
I would much prefer even this way.
12-22-2011 10:29 AM - edited 12-22-2011 10:31 AM
Steve.
try this first
I'm not sure why the default clean-up parameters were chosen- play around with them a bit and Ctrl+U gets better
12-22-2011 10:41 AM
I tried those settings but didn't like the result. Maybe I will try to tweak the settings but I very seldom use cleanup. When I do it is on other peoples code ![]()
12-22-2011 11:46 AM
@Steve Chandler wrote:
I tried those settings but didn't like the result. Maybe I will try to tweak the settings but I very seldom use cleanup. When I do it is on other peoples code
I'm the same way. If the error wire isn't perfectly straight from ErrIn to ErrOut, there'd better be a damn good reason for being even 1 pixel off. ![]()
(kinda the reasoning behind my "align objects by error wire" idea)
12-22-2011 11:54 AM
@Steve Chandler wrote:
I tried cleanup. It does help a lot but readability is only part of it. It is still hard to add things in the middle. It isn't that hard but I am lazy that way. Also for me it is easier to read code if there are less wires. Don't get me wrong - I like wires! I just don't like when there are too many of them because it makes me dizzy. The original could have at least concatenated the semicolon and linefeed separately and wired the output between each constant in the other concatenate. I still don't like it because there is a wire going to way too many nodes.
Now that I think about it the thing that bothers me about concatenating a bunch of constants is when you have something like a linefeed between each.
I would much prefer even this way.
Wait!! Wait!! wait!!!
You're original solution still holds true to be the better one. This one is just a cleaned up representation of the same Rube Goldberg.
So it's still a Rube. Making it a non-Rube does cause the block diagram to be cleaner. 🙂
For me, using the \ display would be better than the vertical tower of letters. I would also use Format Into String.
This one does border with... bad dog... I mean bad code.. It certainly would not meet our internal coding guideline... and as such, it would be considered bad code..