Comment On Ask Rumen

"We recently inherited an ancient ASP.NET application," Misho D writes, "well, ancient as in .NET. The development started around 2002 and the maintenance never seems to end." "Given that it was probably the original team's first .NET (or one of the first) .NET applications, the WTF-to-line ratio is pretty high. But there's one recurring theme throughout the code that is baffling: some guy named Rumen. His name and comments are all throughout the code." [expand full text]
« PrevPage 1 | Page 2Next »

Re: Ask Rumen

2009-10-19 09:06 • by Willie Makeit (unregistered)
// Ask Rumen which post this was

Re: Ask Rumen

2009-10-19 09:08 • by Tim (unregistered)
Better make safe that ImgHeight is initialized to 0 by setting it twice...

Re: Ask Rumen

2009-10-19 09:10 • by anonymous coward (unregistered)
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)

Re: Ask Rumen

2009-10-19 09:10 • by akatherder
288337 in reply to 288334
Willie Makeit:
// Ask Rumen which post this was


You'll need an instance of the GetWhichPostFactory.

Re: Ask Rumen

2009-10-19 09:18 • by Willie Makeit (unregistered)
288338 in reply to 288337
akatherder:
Willie Makeit:
// Ask Rumen which post this was


You'll need an instance of the GetWhichPostFactory.


I won't. I don't care

Re: Ask Rumen

2009-10-19 09:21 • by mystery (unregistered)
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....

Re: Ask Rumen

2009-10-19 09:27 • by eViLegion (unregistered)
288340 in reply to 288339
mystery:
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?

Re: Ask Rumen

2009-10-19 09:31 • by highphilosopher (unregistered)
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.

Re: Ask Rumen

2009-10-19 09:31 • by Rumen (unregistered)
Hey, what's up ?

Re: Ask Rumen

2009-10-19 09:36 • by Martin (unregistered)
Well, why didn't the devs ask Rumen? It's the most obvious way to figure it out.

Re: Ask Rumen

2009-10-19 09:36 • by Dinnerbone
Rumen:
int imgHeight = 0;

int imgHeight = 0;


Surely this'll give a compiler error?

Re: Ask Rumen

2009-10-19 09:51 • by Anon (unregistered)
Given that it was probably the original team's first .NET (or one of the first) .NET applications


I think we have a bracket mismatch here. Or at least we don't need the first .NET

Re: Ask Rumen

2009-10-19 09:56 • by Patrick (unregistered)
288346 in reply to 288344
Dinnerbone:
Rumen:
int imgHeight = 0;

int imgHeight = 0;


Surely this'll give a compiler error?

Probably a copy/paste error

Re: Ask Rumen

2009-10-19 10:01 • by //Rumen (unregistered)
288347 in reply to 288334
Willie Makeit:
// Ask Rumen which post this was


It was 'FIST!'

Any other questions while I am here?

Re: Ask Rumen

2009-10-19 10:03 • by lolwtf
Yeah. WTF?

And why do I have to submit this comment 3 times?

Re: Ask Rumen

2009-10-19 10:10 • by SR (unregistered)
288349 in reply to 288341
highphilosopher:
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.


When something has been made idiot-proof, someone will invent a better idiot

Re: Ask Rumen

2009-10-19 10:12 • by Floyd (unregistered)
Additional WTF: Thou shalt not use System.Drawing from ASP.Net applications. See here.

Re: Ask Rumen

2009-10-19 10:12 • by SenTree
288351 in reply to 288345
Anon:
Given that it was probably the original team's first .NET (or one of the first) .NET applications

I think we have a bracket mismatch here. Or at least we don't need the first .NET

Or, indeed, any. </cheap wisecrack>

Re: Ask Rumen

2009-10-19 10:14 • by xtremezone
Hey, at least he's using a `using' statement. :P

Re: Ask Rumen

2009-10-19 10:15 • by justsomedude (unregistered)
288353 in reply to 288352
lolwtf:
Yeah. WTF?

And why do I have to submit this comment 3 times?


Once for the server, once to display to clients, and once for Rumen of course!

Re: Ask Rumen

2009-10-19 10:15 • by uox (unregistered)
288354 in reply to 288345
Anon:
Given that it was probably the original team's first .NET (or one of the first) .NET applications

We don't need .NET


FTFY

Re: Ask Rumen

2009-10-19 10:22 • by Kim (unregistered)
288355 in reply to 288350
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...

Re: Ask Rumen

2009-10-19 10:32 • by Coyne
It makes my head hurt to "Rumen-ate" on this article.

Re: Ask Rumen

2009-10-19 10:35 • by awerfaewff (unregistered)
If only he knew about Ioc and DI. Then this wouldn't have happened.

Re: Ask Rumen

2009-10-19 10:38 • by Rootbeer
288358 in reply to 288340
eViLegion:
mystery:
It doesn't take a genius to work out what happened next....


Someone got fired?


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.

Re: Ask Rumen

2009-10-19 10:43 • by Bim Job (unregistered)
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?

Re: Ask Rumen

2009-10-19 10:59 • by bob (unregistered)
This is poor stuff. This is truly poor stuff.


Absolutely.

I DEMAND TOLSTOY.

Re: Ask Rumen

2009-10-19 11:01 • by SR (unregistered)
288363 in reply to 288359
Bim Job:
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?


A little harsh, there. I actually LOLed.

Re: Ask Rumen

2009-10-19 11:39 • by Manzoor (unregistered)
288366 in reply to 288355
What should be done then?

Re: Ask Rumen

2009-10-19 11:45 • by Beggars Cant Be Choosers (unregistered)
288367 in reply to 288359
Bim Job:
This is poor stuff. This is truly poor stuff.

Where's WaldoWTF?


Submit something better.

Re: Ask Rumen

2009-10-19 11:47 • by pedric
You could, like, ask Rumen for TRWTF!

Re: Ask Rumen

2009-10-19 12:09 • by amischiefr
288369 in reply to 288344
Dinnerbone:
Rumen:
int imgHeight = 0;

int imgHeight = 0;


Surely this'll give a compiler error?

No, it won't, and stop calling me Surely.

Re: Ask Rumen

2009-10-19 12:13 • by Loris (unregistered)
288370 in reply to 288345
Anon:
Given that it was probably the original team's first .NET (or one of the first) .NET applications


I think we have a bracket mismatch here. Or at least we don't need the first .NET (or one of the first).NET


FTFY

Re: Ask Rumen

2009-10-19 12:29 • by Stilgar
Note how he cleverly disabled any caching:)

Re: Ask Rumen

2009-10-19 12:31 • by JV (unregistered)
288373 in reply to 288350
Floyd:
Additional WTF: Thou shalt not use System.Drawing from ASP.Net applications. See here.

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.

Re: Ask Rumen

2009-10-19 12:41 • by Stilgar
288374 in reply to 288373
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...

Re: Ask Rumen

2009-10-19 12:43 • by Not Rumen (unregistered)
This is worse than Spaghetti code- It's Rumen Noodle code.

Re: Ask Rumen

2009-10-19 12:50 • by Tisho (unregistered)
COOL :D

Re: Ask Rumen

2009-10-19 13:38 • by Tolstoy (unregistered)
288379 in reply to 288362
bob:
This is poor stuff. This is truly poor stuff.


Absolutely.

I DEMAND TOLSTOY.

I've been here all along. What did you want?

Re: Ask Rumen

2009-10-19 13:40 • by Chris Chubb (unregistered)
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.

Re: Ask Rumen

2009-10-19 13:46 • by Jeffrey (unregistered)
288381 in reply to 288339
mystery:
It doesn't take a genius to work out what happened next....

He fixes the cable?

Re: Ask Rumen

2009-10-19 14:00 • by Carl (unregistered)
try
{
...buncha important stuff...
}
catch
{
imgHeight = 85;
}

I encountered an error while trying to decide what to say about this, so I'll just say... 85.

Re: Ask Rumen

2009-10-19 14:02 • by hikari
288383 in reply to 288344
Dinnerbone:
Rumen:
int imgHeight = 0;

int imgHeight = 0;


Surely this'll give a compiler error?


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.

Re: Ask Rumen

2009-10-19 14:11 • by Procedural (unregistered)
288385 in reply to 288374
Stilgar:
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...


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 ?

Re: Ask Rumen

2009-10-19 14:26 • by Evo
288386 in reply to 288383
hikari:
Dinnerbone:
Rumen:
int imgHeight = 0;

int imgHeight = 0;


Surely this'll give a compiler error?


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.


You just proved that C# is TRWTF.

Re: Ask Rumen

2009-10-19 14:26 • by Squire (unregistered)
288387 in reply to 288383
Of course it gives a compiler error, the variable is being declared twice:

int imgHeight = 0;

int imgHeight = 0;
test.cs(8,7): error CS0128: A local variable
named 'imgHeight' is already defined in this scope


And the initialization is absolutely required:

int imgHeight;

Console.WriteLine(imgHeight);
test.cs(8,21): error CS0165: Use of unassigned
local variable 'imgHeight'

Re: Ask Rumen

2009-10-19 14:34 • by Squire (unregistered)
288388 in reply to 288386
Evo:
hikari:
Dinnerbone:
Rumen:
int imgHeight = 0;

int imgHeight = 0;


Surely this'll give a compiler error?


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.


You just proved that C# is TRWTF.


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

int imgHeight = 0;
int imgHeight = 0;

test.cs(8,7): error CS0128: A local variable named
'imgHeight' is already defined in this scope

// not initializing a variable

int imgHeight;
Console.WriteLine(imgHeight);

test.cs(8,21): error CS0165: Use of unassigned local
variable 'imgHeight'

Re: Ask Rumen

2009-10-19 14:36 • by jpa
288389 in reply to 288350
Floyd:
Additional WTF: Thou shalt not use System.Drawing from ASP.Net applications. See here.


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 --"

Re: Ask Rumen

2009-10-19 14:38 • by C# Man (unregistered)
288390 in reply to 288383
hikari:
Dinnerbone:
Rumen:
int imgHeight = 0;

int imgHeight = 0;


Surely this'll give a compiler error?


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.


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.

Re: Ask Rumen

2009-10-19 14:45 • by C# Man (unregistered)
288391 in reply to 288350
Floyd:
Additional WTF: Thou shalt not use System.Drawing from ASP.Net applications. See here.


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!?
« PrevPage 1 | Page 2Next »

Add Comment