|
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.
|
|
|
|
|
"We all come across code that simply boggles the mind. Lazy kludges, embarrasing mistakes..."
Spell check embarrasing....should be embarrassing...
73
|
|
|
|
|
Ever heard of self-referential irony?
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
I think it was just a mistake.
------------------------------------
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[ ^]
|
|
|
|
|
Spoiler!
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
He just spoiled the spoiling
|
|
|
|
|
This is the loop that generates our main menu , all on one line:
<% int i = 1; foreach (Fatthallah.Web.HttpHandler.PetraMainMenu mainMenuItem in mainMenuCollection) { Response.Write("<li style=\"float:" + (lang == "en" ? "left" : "right") + "\"><a id =\"a" + i + "\" name=\"a" + i + "\" href=\"" + (mainMenuItem.MainMenuLink.Trim().Length > 0 ? ResolveUrl("~/" + mainMenuItem.MainMenuLink.Split('?')[0] + "lang=" + lang + "&" + mainMenuItem.MainMenuLink.Split('?')[1]) : "javascript:void(0)") + "\" onclick=\"fetchData('menuHandler.axd','hml','menu=true&id=" + mainMenuItem.MainMenuId + "&lang=" + lang + "',this);return false;\" onmouseout=\"hidebox(this);\" >" + (mainMenuItem.MainMenuTitleEnglish.Trim().Length > 0 && lang == "en" ? mainMenuItem.MainMenuTitleEnglish : mainMenuItem.MainMenuTitleArabic) + "</a></li>"); i++; } Response.Write("<script language='javascript' type='text/javascript'>mainMenuCounter =" + mainMenuCollection.ToArray().Length + "; var rtl=" + (lang == "en" ? "false" : "true") + ";</script>"); %>
My eyes are bleeding, and that's before I start the rant about how we keep our site bilingual and why we use JavaScript to replace what could be achieved with hyperlinks.
[Edit]
After a simple tidying exercise:
<%
int i = 1;
foreach (Fatthallah.Web.HttpHandler.PetraMainMenu mainMenuItem in mainMenuCollection)
{
Response.Write("<li style=\"float:"
+ (lang == "en" ? "left" : "right")
+ "\"><a id =\"a" + i
+ "\" name=\"a" + i
+ "\" href=\"" + (mainMenuItem.MainMenuLink.Trim().Length > 0 ? ResolveUrl("~/" + mainMenuItem.MainMenuLink.Split('?')[0]
+ "lang=" + lang
+ "&" + mainMenuItem.MainMenuLink.Split('?')[1]) : "javascript:void(0)") + "\" onclick=\"fetchData('menuHandler.axd','hml','menu=true&id=" + mainMenuItem.MainMenuId
+ "&lang=" + lang + "',this);return false;\" onmouseout=\"hidebox(this);\" >"
+ (mainMenuItem.MainMenuTitleEnglish.Trim().Length > 0 && lang == "en" ? mainMenuItem.MainMenuTitleEnglish : mainMenuItem.MainMenuTitleArabic)
+ "</a></li>");
i++;
}
Response.Write("<script language='javascript' type='text/javascript'>mainMenuCounter =" + mainMenuCollection.ToArray().Length + "; var rtl=" + (lang == "en" ? "false" : "true") + ";</script>");
%>
I think it was put on one line "keep our pages small" by removing unecessary whitespace, but this is code to generate html so it doesn't count. In any case it is still 100 times more complicated and convoluted than it needs to be for our purposes.
|
|
|
|