Does this line of code bother anyone?
-
A whipper-snapper (sort-of) on my team wrote this:
for (index = 0; index < num\_systems && systems\[index\].type == SYSTEM\_TYPE\_XYZ && (systems\[index\].name, "XYZname"); ++index);
I don't care very much for excessive cleverness. I care for maintainability. And debug-ability. This does not meet that requirement for me. Does anyone else feel this way? I am feeling old and curmudgeonly about this, however I want some honest opinions.
-
A whipper-snapper (sort-of) on my team wrote this:
for (index = 0; index < num\_systems && systems\[index\].type == SYSTEM\_TYPE\_XYZ && (systems\[index\].name, "XYZname"); ++index);
I don't care very much for excessive cleverness. I care for maintainability. And debug-ability. This does not meet that requirement for me. Does anyone else feel this way? I am feeling old and curmudgeonly about this, however I want some honest opinions.
Here's my take on this. If you need a minute to think about what a code statement does, then it has to go. Get rid of it.
«_Superman_» _I love work. It gives me something to do between weekends.
_Microsoft MVP (Visual C++) (October 2009 - September 2013)
-
A whipper-snapper (sort-of) on my team wrote this:
for (index = 0; index < num\_systems && systems\[index\].type == SYSTEM\_TYPE\_XYZ && (systems\[index\].name, "XYZname"); ++index);
I don't care very much for excessive cleverness. I care for maintainability. And debug-ability. This does not meet that requirement for me. Does anyone else feel this way? I am feeling old and curmudgeonly about this, however I want some honest opinions.
-
A whipper-snapper (sort-of) on my team wrote this:
for (index = 0; index < num\_systems && systems\[index\].type == SYSTEM\_TYPE\_XYZ && (systems\[index\].name, "XYZname"); ++index);
I don't care very much for excessive cleverness. I care for maintainability. And debug-ability. This does not meet that requirement for me. Does anyone else feel this way? I am feeling old and curmudgeonly about this, however I want some honest opinions.
Quote:
(systems[index].name, "XYZname")
?!?
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?! -- C++ FQA Lite
-
Here's my take on this. If you need a minute to think about what a code statement does, then it has to go. Get rid of it.
«_Superman_» _I love work. It gives me something to do between weekends.
_Microsoft MVP (Visual C++) (October 2009 - September 2013)
-
Quote:
(systems[index].name, "XYZname")
?!?
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?! -- C++ FQA Lite
I know! The line does not even do what the coder intends it to do. Too bad the compiler did not complain. That alone is reason enough to 86 it, of course. This program is rife with this kind of stuff. Some of it may even work, but as Superman says, I should not have to spend more than a moment understand it..
-
A whipper-snapper (sort-of) on my team wrote this:
for (index = 0; index < num\_systems && systems\[index\].type == SYSTEM\_TYPE\_XYZ && (systems\[index\].name, "XYZname"); ++index);
I don't care very much for excessive cleverness. I care for maintainability. And debug-ability. This does not meet that requirement for me. Does anyone else feel this way? I am feeling old and curmudgeonly about this, however I want some honest opinions.
It's like a long paragraph with no commas or punctuation.
cheers Chris Maunder
-
Quote:
(systems[index].name, "XYZname")
?!?
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?! -- C++ FQA Lite
The result of that part of the condition would be the same as
static_cast(system[index].name)
The string literal will be evaluated but the result of the comma operator is always the leftmost argument. (You probably know that, but I thought I should offer an explanation for less experienced readers) My guess is this was supposed to be a string comparison. Not that it makes the condition look any better... Oh, and btw., I know that '
??!
' is the trigraph for '|
', but I'm not familiar with '?!?
'. Typo? ;PGOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)