|
Yar. In my opinion BETWEEN should be >= && <
|
|
|
|
|
Exactamundo. It should be [A,B) because those intervals can be put next to each other without overlap. I've had to deal with a few stored procs that have comments recording the changes from + ' 23:59' to + ' 23:59:59' to + ' 23:59:59.999' etc. as the edge cases were slowly uncovered.
|
|
|
|
|
CmdVal has better be "T","F" or "Else"
Public Sub SetWrite(ByVal CmdVal As String)
Select Case UCase(CmdVal)
Case "T"
m_WriteOutErrorLog = True
Case "F"
m_WriteOutErrorLog = False
Case "Else"
MsgBox("Error: Error Logging Parameter not recognised, should be 'T' or 'F'")
End Select
End Sub
|
|
|
|
|
The "or else" my parents would use to threaten me! Glad to see it's made its way into the hall of shame.
"I have a theory that the truth is never told during the nine-to-five hours. "
— Hunter S. Thompson
|
|
|
|
|
Trying to debug some old code written 3-4years ago by a previous employee and came across this - I can't decide if he's a hero or an idiot, what do you think? (and before anyone says it, yes I know its legal - and it works (mostly) but try debugging it when it doesn't!)
for (; (Var1 < Var2) && (Var3 == FALSE) && ( ( Var4 < 0 ) || (Var5 <= Var6) ); Var7++)
{
.
.
.
.
}
|
|
|
|
|
He deserves a medal for being able to construct it!
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC Link[ ^]
Trolls[ ^]
|
|
|
|
|
Well "700 lines of code in a block" = Idiot.
|
|
|
|
|
True. Everybody knows the limit is 558 lines.
Martin Fowler wrote: Any fool can write code that a computer can understand. Good programmers write code that humans can understand.
|
|
|
|
|
it's an coding constant... like the speed of light
(yes|no|maybe)*
|
|
|
|
|
Maybe someone told them the while statement was going to be deprecated.
And they believed it!
I also like the title case for variable names.
"You get that on the big jobs."
|
|
|
|
|
To be fair I changed the variables names myself (to protect the guilty). Capitalising variable names is something I've always done, 20 years or more, it's a hard habit to break - old dog and new tricks if you know what I mean
|
|
|
|
|
Never seen something like that... but it's kind of... attractive... in a way... strange way... forbidden way...
(yes|no|maybe)*
|
|
|
|
|
You must resist - its a sure path to the dark side...
|
|
|
|
|
... I can't... have to write... strange code... oops, no it's been
while
(yes|no|maybe)*
|
|
|
|
|
for(;1==1;i++){if(!i)goto End;}
End:
Still tempted?
|
|
|
|
|
do ne it, until it feels false
(yes|no|maybe)*
|
|
|
|
|
Hard to tell given the level of anonymisation you've done. If it's a hard problem then such a complex test might be appropriate. I'd probably write it as a while loop, since the 'incrementer' is a different variable.
I do agree though that the 'Real WTF' is the 700 lines inside a loop construct.
|
|
|
|
|
Ok.. so far I can buy smart.. although I'm not fond of HOW the code is formatted.. I try to format more complex if statements so that its obvious what is going on.. ergo:
for ( ;
(Var1 < Var2)
&& (Var3 == FALSE)
&& ( ( Var4 < 0 )
|| (Var5 <= Var6) );
Var7++)
{
.
.
.
.
}
I used to do PLC programming and loved how ladder logic read.. so this is a hold over from those days for me.. I'm ALL about readability..
On 700 lines.. idiot for sure.
Now.. my question to determine if this guys is a TRUE idiot.. does he re-use any of those test variables for other purposes in his massive 700 line pile of spaghetti? If so.. then he gets promoted to 'Principle Idiot'.
The reason I ask this is.. I've seen that.. a 3000 line function that re-used control and locally declared variables for complete different purposes.. trying to debug that mess was like messing with a wierd 3-dimensional puzzle. The guy that wrote it, god bless his soul, at least wasn't a CS guy.. he was a business analyst. Give a child a pistol....
|
|
|
|
|
Var1 - 17 references
Var2 - 5 references
Var3 - 14 references...
...and so on - believe me its spaghetti!
|
|
|
|
|
That's downright amazing. I don't think I would have ever thought of that. It really makes you wonder, who does think like that? Was the author an expert in regex per chance?
|
|
|
|
|
From a console tic-tac-toe game: (drawing function)
for (int x = 0, y = 0; y < 3; y+=((x==2)?1:0),x+=((x==2)?-2:1) ) {
cout << boardStrings[board[x][y]] << ((x == 2) ? "\n" : "");
}
|
|
|
|
|
I hate to say it, but I quite like that code. With a couple of named constants instead of the use of literals 2 and 3 and more consistant spacing it would be nice and succinct.
|
|
|
|
|
I'm glad to say that i like this code No horror there i my opinion.
- oggenok
|
|
|
|
|
While I do use the comma operator, I do so sparingly. I also like code to be easily readable, which this example is not.
Just because the code works, it doesn't mean that it is good code.
|
|
|
|
|
That's not really bad, to me. Initialising and updating two variables in a loop is one of the well understood allowed places to use a comma. The thing that's wrong with this code is that the 3x3 nature of the board should be a variable (or at least a constant), not in there as a magic number 5 times.
|
|
|
|