12-15-2011 12:01 PM
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
12-21-2011 03:22 PM
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.
12-22-2011 03:36 AM
@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.
12-22-2011 07:11 AM
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
12-22-2011 07:20 AM - edited 12-22-2011 07:20 AM
I like your point, James.
To my opinion, readability of the BD is the top-level concern. Especially when performance doesn't matter.
Guenter
12-22-2011 07:29 AM
@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.
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
12-22-2011 07:41 AM - edited 12-22-2011 07:42 AM
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.
12-22-2011 07:51 AM
@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
12-22-2011 08:18 AM
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.
12-22-2011 08:37 AM
Ok, Steve. This one convinces even me.