- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
// Ask Rumen which post this was
Admin
Better make safe that ImgHeight is initialized to 0 by setting it twice...
Admin
With appologies to Antony (and Shakespeare) ...
Friends, Rumen, Countrymen I come not to praise this code but to bury it The evil that men do lives after them...
Captcha: luctus - very appropriately Roman (or Rumen)
Admin
You'll need an instance of the GetWhichPostFactory.
Admin
I won't. I don't care
Admin
This is nothing compared to what one of our devs did. Granted we're talking PHP here but the same thing can arguably happen in any language and is basically the same thing seen here but X1000 times worse.
It all happened when we noticed our main web server was grinding to a halt each day at roughly the same time. At first we dismissed it as a random event. When it didn't go away and in fact for worse an investigation was necessary.
After checking several things I finally came upon the access log. In here I saw something strange. A single file had been gotten over and over in very quick succession. It had tens of thousands of hits in a matter of seconds. Goodness knows how much overall. What turned out to be stranger is that all of the requests originated from the webserver's own IP.
So I checked the file and to cut a long story short the dev had somehow managed to get the php file to include it's self in a circular fashion over the web. It doesn't take a genius to work out what happened next....
Admin
Someone got fired?
Admin
This just goes to show you that if you try to dummy proof a language, then a lot of dummies will try to use it.
Admin
Hey, what's up ?
Admin
Well, why didn't the devs ask Rumen? It's the most obvious way to figure it out.
Admin
Surely this'll give a compiler error?
Admin
I think we have a bracket mismatch here. Or at least we don't need the first .NET
Admin
Admin
It was 'FIST!'
Any other questions while I am here?
Admin
Yeah. WTF?
And why do I have to submit this comment 3 times?
Admin
When something has been made idiot-proof, someone will invent a better idiot
Admin
Additional WTF: Thou shalt not use System.Drawing from ASP.Net applications. See here.
Admin
Admin
Hey, at least he's using a `using' statement. :P
Admin
Once for the server, once to display to clients, and once for Rumen of course!
Admin
FTFY
Admin
Too bad you didn't read the whole thing...
"Classes within the System.Drawing namespace are not supported for use within a Windows or ASP.NET service. Attempting to use these classes from within one of these application types may produce unexpected problems, such as diminished service performance and run-time exceptions."
ASP.NET applications isn't ASP.NET services...
Admin
It makes my head hurt to "Rumen-ate" on this article.
Admin
If only he knew about Ioc and DI. Then this wouldn't have happened.
Admin
Hopefully it was the "someone" who dismissed an event that happened at the same time every day as "random" without even having glanced at the access logs.
Admin
So:
... and the kicker ...
This is poor stuff. This is truly poor stuff.
Where's WaldoWTF?
Admin
Absolutely.
I DEMAND TOLSTOY.
Admin
A little harsh, there. I actually LOLed.
Admin
What should be done then?
Admin
Submit something better.
Admin
You could, like, ask Rumen for TRWTF!
Admin
Admin
FTFY
Admin
Note how he cleverly disabled any caching:)
Admin
Captcha: Decet = A pair of decimal digits. See also Octet and Hexet.
Admin
He didn't need the size because there are many ways to set the size of a container to the size of what is inside it with CSS.
BTW I submitted this and to be honest I am not 100% sure Rumen added the part with the image however he's put comments with his name over many other WTFs and his name was in the file's header so...
Admin
This is worse than Spaghetti code- It's Rumen Noodle code.
Admin
COOL :D
Admin
Admin
Thanks, I was looking for a compact .NET example of how to get an images dimensions. I'll be sure to call it twice, once for height and I'll copy/paste a version for width while I am at it.
Admin
Admin
Admin
No. Why would it? It's completely valid. Pointless, but valid. It won't even give you a warning, unless you use an add-on like ReSharper, which will go "why are you being stupid?" at you.
In fact in C# the initialization is pointless anyway, default(int) is 0.
Admin
We don't have the context. If you are preparing that HTML for an e-mail report (with clients who use Outlook) then forget about CSS (or any other kind of standard).
It looks to me like the first bit of code was a hack of some sort that was used during development, and was later commented out. So the real WTF is:
Did we run out of incompetence, or just of tattletales ?
Admin
You just proved that C# is TRWTF.
Admin
Of course it gives a compiler error, the variable is being declared twice:
And the initialization is absolutely required:
Admin
Actually he didn't prove anything of the kind because he is incorrect on all points:
test.cs(8,7): error CS0128: A local variable named 'imgHeight' is already defined in this scope
test.cs(8,21): error CS0165: Use of unassigned local variable 'imgHeight'
Admin
The real WTF: Does ASP.Net really not have a decent graphics library out-of-box?
Also compare this MSDN blog post with the statement above mentioned statement on MSDN. "The Microsoft .NET Framework contains an abundance of classes in the System.Drawing namespace that can be used—in a standalone Windows®-based application or on an ASP.NET Web page --"
Admin
No, it DOES give an error. C# is all strongly statically typed, like Java. Everyone has to be initialised to the correct type, can't change type, can only declare it once etc. etc.
Admin
Why on earth not!?
It's true that it could hurt performance on a highly scalable web application, but any sort of dynamic image generation or analyses will, if you need it then you don't have much choice and just have to find ways to work around the performance issues just as with anything else web related.
PS: Why is DailyWTF giving me so many error messages when trying to submit comments!?