Clever Coder or Annoying SmartAss?
-
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++)
{
.
.
//700 lines of code
.
.
} -
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++)
{
.
.
//700 lines of code
.
.
} -
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++)
{
.
.
//700 lines of code
.
.
} -
True. Everybody knows the limit is 558 lines. :rolleyes:
Martin Fowler wrote:
Any fool can write code that a computer can understand. Good programmers write code that humans can understand.
-
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++)
{
.
.
//700 lines of code
.
.
} -
True. Everybody knows the limit is 558 lines. :rolleyes:
Martin Fowler wrote:
Any fool can write code that a computer can understand. Good programmers write code that humans can understand.
-
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++)
{
.
.
//700 lines of code
.
.
} -
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."
-
Never seen something like that... but it's kind of... attractive... in a way... strange way... forbidden way... :-O
(yes|no|maybe)*
-
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++)
{
.
.
//700 lines of code
.
.
}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.
-
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++)
{
.
.
//700 lines of code
.
.
}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++)
{
.
.
//700 lines of code
.
.
}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....
-
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++)
{
.
.
//700 lines of code
.
.
}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....
-
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++)
{
.
.
//700 lines of code
.
.
}