|
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 ♫
|
|
|
|
|
|
There is a semantic difference between <p> (or other similar elements like <pre> and <dd>) and <br> (and I don't just mean that one is a container tag and one is a separator). It's not just a matter of (ab)using styles to make one look like the other. A paragraph is one group of related text, which may have explicit line breaks (<br> or, if being XHTML compliant, <br/>) within it. <br> shouldn't be used to split paragraphs, any more than <p> should be used to cause an in-paragraph line break, even if you can mess with the styles so that is the appearance.
(An exception would be code listings where it's usual to run the whole thing inside one <pre>, even though one could logically argue that it should be one per method.)
|
|
|
|
|
I have no idea why so many people are touting the new MVC3 model and Razor view engine. My point here is when classic ASP was the thing we mixed code and HTML on the same page and by god does it look like hell when you do. So when Microsoft allowed you to inline code into your application it really did nothing to stop lousy code practices. And placing all the logic into the code behind was a much cleaner separation of concerns then ASP ever was. But now we have come full circle with Razor which promotes mixed mode files again. Granted it looks better then classic ASP it doesn't look as clean as ASP.NET using code behind. There still needs to be a better way for auto generated code to be passed around without resorting to concatenation of mixed forms of code. Its just sloppy.
nothing
|
|
|
|
|
... Did you look where you were posting?
Don't forget to rate my post if it helped!
"He has no enemies, but is intensely disliked by his friends."
"His mother should have thrown him away, and kept the stork."
"There's nothing wrong with you that reincarnation won't cure."
"He loves nature, in spite of what it did to him."
|
|
|
|