• Willie Makeit (unregistered)

    // Ask Rumen which post this was

  • Tim (unregistered)

    Better make safe that ImgHeight is initialized to 0 by setting it twice...

  • 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)

  • (cs) in reply to Willie Makeit
    Willie Makeit:
    // Ask Rumen which post this was

    You'll need an instance of the GetWhichPostFactory.

  • Willie Makeit (unregistered) in reply to akatherder
    akatherder:
    Willie Makeit:
    // Ask Rumen which post this was

    You'll need an instance of the GetWhichPostFactory.

    I won't. I don't care

  • 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....

  • eViLegion (unregistered) in reply to mystery
    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?

  • 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.

  • Rumen (unregistered)

    Hey, what's up ?

  • Martin (unregistered)

    Well, why didn't the devs ask Rumen? It's the most obvious way to figure it out.

  • (cs)
    Rumen:
    int imgHeight = 0;
    int imgHeight = 0;

    Surely this'll give a compiler error?

  • 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

  • Patrick (unregistered) in reply to Dinnerbone
    Dinnerbone:
    Rumen:
    int imgHeight = 0;
    int imgHeight = 0;

    Surely this'll give a compiler error?

    Probably a copy/paste error

  • //Rumen (unregistered) in reply to Willie Makeit
    Willie Makeit:
    // Ask Rumen which post this was

    It was 'FIST!'

    Any other questions while I am here?

  • (cs)

    Yeah. WTF?

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

  • SR (unregistered) in reply to highphilosopher
    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

  • Floyd (unregistered)

    Additional WTF: Thou shalt not use System.Drawing from ASP.Net applications. See here.

  • (cs) in reply to Anon
    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>
  • (cs)

    Hey, at least he's using a `using' statement. :P

  • justsomedude (unregistered) in reply to xtremezone
    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!

  • uox (unregistered) in reply to Anon
    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

  • Kim (unregistered) in reply to Floyd

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

  • (cs)

    It makes my head hurt to "Rumen-ate" on this article.

  • awerfaewff (unregistered)

    If only he knew about Ioc and DI. Then this wouldn't have happened.

  • (cs) in reply to eViLegion
    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.

  • 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?

  • bob (unregistered)
    This is poor stuff. This is truly poor stuff.

    Absolutely.

    I DEMAND TOLSTOY.

  • SR (unregistered) in reply to Bim Job
    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.

  • Manzoor (unregistered) in reply to Kim

    What should be done then?

  • Beggars Cant Be Choosers (unregistered) in reply to Bim Job
    Bim Job:
    This is poor stuff. This is truly poor stuff.

    Where's WaldoWTF?

    Submit something better.

  • (cs)

    You could, like, ask Rumen for TRWTF!

  • (cs) in reply to Dinnerbone
    Dinnerbone:
    Rumen:
    int imgHeight = 0;
    int imgHeight = 0;

    Surely this'll give a compiler error?

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

  • Loris (unregistered) in reply to Anon
    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

  • (cs)

    Note how he cleverly disabled any caching:)

  • JV (unregistered) in reply to Floyd
    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.

  • (cs) in reply to JV

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

  • Not Rumen (unregistered)

    This is worse than Spaghetti code- It's Rumen Noodle code.

  • Tisho (unregistered)

    COOL :D

  • Tolstoy (unregistered) in reply to bob
    bob:
    This is poor stuff. This is truly poor stuff.

    Absolutely.

    I DEMAND TOLSTOY.

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

  • 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.

  • Jeffrey (unregistered) in reply to mystery
    mystery:
    It doesn't take a genius to work out what happened next....
    He fixes the cable?
  • 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.
  • (cs) in reply to Dinnerbone
    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.

  • Procedural (unregistered) in reply to Stilgar
    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 ?

  • (cs) in reply to hikari
    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.

  • Squire (unregistered) in reply to hikari

    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'
  • Squire (unregistered) in reply to Evo
    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'

  • (cs) in reply to Floyd
    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 --"

  • C# Man (unregistered) in reply to hikari
    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.

  • C# Man (unregistered) in reply to Floyd
    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!?

Leave a comment on “Ask Rumen”

Log In or post as a guest

Replying to comment #:

« Return to Article