|
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.
|
|
|
|
|
Art, man, it's a... no... forget it... my eyes are bleeding too could we get a smiley... sadey with red tears?
(yes|no|maybe)*
|
|
|
|
|
Really...
Who said boys don't cry...
|
|
|
|
|
Another sample from our code base...
If UCase(optionText) = "True" Or optionText="1" Then
' Some code here
End If
Further down in the function, there's a test for Windows 3.1, so I guess this has been in place a while. Still no excuse though.
|
|
|
|
|
your not wRONG
"You get that on the big jobs."
|
|
|
|
|
Trick question! Neither. Just found this:
</br>
And, no, there was not an opening BR. Just a long list of anchor tags separated by this new form of BR tag.
Driven to the ARMs by x86.
|
|
|
|
|
you </br> idge the gap...
(yes|no|maybe)*
|
|
|
|
|
Oh, it still works when omitting the opening tag? Cool, then I can omit that one in my code and have faster page loading!
|
|
|
|
|
Burning </br>idges, obviously.
Seriously, what is the world coming to?????
(P.S. and shouldn't he have been using <p> or <li> or...)
-- Modified Sunday, July 17, 2011 3:28 AM
|
|
|
|
|
another one that I have seen is <br />
it depends on whether it is html or Microsoft html as to whether you take the < p > and use styles to make it work like <br>
< p > is because I couldn't get the tag to show until I put spaces in it, even though I put it in code tags
|
|
|
|
|
<br /> is correct and is required for XHTML. For other HTML versions, there is no closing marker. In other words, there is never a </br> tag, since the BR element cannot contain anything.
And if you are using something called "Microsoft HTML", then get off my Internet!
Narf.
|
|
|
|
|
// ♫ 99 little bugs in the code,
// 99 bugs in the code
// We fix a bug, compile it again
// 101 little bugs in the code ♫
|
|
|
|
|