| « Prev | Page 1 | Page 2 | Next » |
|
// Ask Rumen which post this was
|
|
Better make safe that ImgHeight is initialized to 0 by setting it twice...
|
|
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) |
You'll need an instance of the GetWhichPostFactory. |
Re: Ask Rumen
2009-10-19 09:18
•
by
Willie Makeit
(unregistered)
|
I won't. I don't care |
|
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.... |
Someone got fired? |
|
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.
|
|
Well, why didn't the devs ask Rumen? It's the most obvious way to figure it out.
|
Surely this'll give a compiler error? |
I think we have a bracket mismatch here. Or at least we don't need the first .NET |
Probably a copy/paste error |
It was 'FIST!' Any other questions while I am here? |
|
Yeah. WTF?
And why do I have to submit this comment 3 times? |
When something has been made idiot-proof, someone will invent a better idiot |
|
Additional WTF: Thou shalt not use System.Drawing from ASP.Net applications. See here.
|
Or, indeed, any. </cheap wisecrack> |
|
Hey, at least he's using a `using' statement. :P
|
Re: Ask Rumen
2009-10-19 10:15
•
by
justsomedude
(unregistered)
|
Once for the server, once to display to clients, and once for Rumen of course! |
FTFY |
|
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... |
|
It makes my head hurt to "Rumen-ate" on this article.
|
|
If only he knew about Ioc and DI. Then this wouldn't have happened.
|
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. |
|
So:
* It uses ASP.NET * There's a hilarious example procedure for which I'm going to invent the term "getter," just to whet our appetite * It uses web access, rather than file access, to retrieve the image in order to calculate dimensions * The library call in question is deprecated, or something (it's probably hard to tell in ASP.NET) * Shock! It's in the page header, so it's always called (see "it uses ASP.NET") ... and the kicker ... * The only instance where it's used is commented out This is poor stuff. This is truly poor stuff. Where's WaldoWTF? |
Absolutely. I DEMAND TOLSTOY. |
A little harsh, there. I actually LOLed. |
|
What should be done then?
|
Re: Ask Rumen
2009-10-19 11:45
•
by
Beggars Cant Be Choosers
(unregistered)
|
Submit something better. |
No, it won't, and stop calling me Surely. |
FTFY |
|
Note how he cleverly disabled any caching:)
|
OK, I give up: How do you find the size of an image in ASP.NET is you can use System.Drawing? Captcha: Decet = A pair of decimal digits. See also Octet and Hexet. |
|
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... |
|
This is worse than Spaghetti code- It's Rumen Noodle code.
|
I've been here all along. What did you want? |
|
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.
|
He fixes the cable? |
I encountered an error while trying to decide what to say about this, so I'll just say... 85. |
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. |
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: 1. Company doesn't prioritize dead code clean up 2. ? 3. Hilarity Did we run out of incompetence, or just of tattletales ? |
You just proved that C# is TRWTF. |
|
Of course it gives a compiler error, the variable is being declared twice:
int imgHeight = 0; And the initialization is absolutely required: int imgHeight; |
Actually he didn't prove anything of the kind because he is incorrect on all points: // declaring the same variable twice in the same scope test.cs(8,7): error CS0128: A local variable named 'imgHeight' is already defined in this scope // not initializing a variable test.cs(8,21): error CS0165: Use of unassigned local variable 'imgHeight' |
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 --" |
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. |
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!? |
| « Prev | Page 1 | Page 2 | Next » |