New design pattern: For loop on something you're not using that still does the work.



  • Well, a new design pattern to me anyway.

    for (int j = 0; j < MAXRATES; j++)
    {
        if (!usingRates && j > 0)
            break;

        // 100 lines of standard stuff that doesn't use j and fits really well into a separate function

        if (usingRates)
        {
            // 20 lines or so which uses rates[j]
        }
        else
        {
            // 20 lines or so which doesn't use j at all.
        }

    I discovered this little suprise left for me when converting the previously fixed size rates array to be a list with no artificial limit and which will now be zero length if you aren't using rates.



  • Ok, I'm drunk and tired, but if there is something that I remember from compiler theory classes is that the computer deals quite well with that kind of WTF, up to the point that I gave up correcting people that use this pattern - and I've met quite a few of them.

     

    Yet, what are they thinking? Are they?



  • @Mithious said:


        // 100 lines of standard stuff that doesn't use j and fits really well into a separate function

     

    Am I poor white trash, or do you guys on thedailyWTF all have monitors that are six feet wide and display five thousand pixels? Very very often I find some posting here where I have to [1] shrink my window to less than full screen, [2] Move the window far to the left, and [3] expand the window to much wider than screen width, sometimes even twice the width of the screen, just to make some long line in a posting be readable to the end of the line.

    Why? What a mess! Please word wrap!

    - Po' Boy in Bangkok.

     

     



  • @Mithious said:

    Well, a new design pattern to me anyway.

    for (int j = 0; j < MAXRATES; j++)
    {
        if (!usingRates && j > 0)
            break;

        // 100 lines of standard stuff that doesn't use j and fits really well into a separate function

        if (usingRates)
        {
            // 20 lines or so which uses rates[j]
        }
        else
        {
            // 20 lines or so which doesn't use j at all.
        }

    I discovered this little suprise left for me when converting the previously fixed size rates array to be a list with no artificial limit and which will now be zero length if you aren't using rates.


    I trust you also changed it to do the non-j parts once even when your new list is empty and the loop doesn't run?



  • @AndyCanfield said:

    @Mithious said:


        // 100 lines of standard stuff that doesn't use j and fits really well into a separate function

     

    Am I poor white trash, or do you guys on thedailyWTF all have monitors that are six feet wide and display five thousand pixels? Very very often I find some posting here where I have to [1] shrink my window to less than full screen, [2] Move the window far to the left, and [3] expand the window to much wider than screen width, sometimes even twice the width of the screen, just to make some long line in a posting be readable to the end of the line.

    Why? What a mess! Please word wrap!

    - Po' Boy in Bangkok.

     

     

    What? This one displays fine on my phone. There are other terrible code examples on this site that doesn't. If it's legible on a 4.x" screen it should be done on a desktop monitor. Unless you're as blind as a bat and use 200% page zoom on a 24" 1280×800?



  • @AndyCanfield said:

    Am I poor white trash, or do you guys on thedailyWTF all have monitors that are six feet wide and display five thousand pixels? Very very often I find some posting here where I have to [1] shrink my window to less than full screen, [2] Move the window far to the left, and [3] expand the window to much wider than screen width, sometimes even twice the width of the screen, just to make some long line in a posting be readable to the end of the line.

    Why? What a mess! Please word wrap!

    - Po' Boy in Bangkok.

    My browser is smart enough to put a horizontal scrollbar when needed.

     



  • @AndyCanfield said:

    Very very often I find some posting here where I have to [1] shrink my window to less than full screen, [2] Move the window far to the left, and [3] expand the window to much wider than screen width, sometimes even twice the width of the screen, just to make some long line in a posting be readable to the end of the line.
     

    Okay, but why post that as a response to a tiny and ompact bit of code of about 30x30 characters?



  • @AndyCanfield said:

    Am I poor white trash, or do you guys on thedailyWTF all have monitors that are six feet wide and display five thousand pixels?
     

    You should get that monitor valued, it might be worth something as an antique. That barely extended across half my screen here.

    @aihtdikh said:

    I trust you also changed it to do the non-j parts once even when your new list is empty and the loop doesn't run?

    Correct. I know why they did it, it's because they couldn't be bothered to move the shared code off to a separate function. This is why we have some 10000 line long functions in the product :/

     



  • @Zemm said:

    @AndyCanfield said:

    @Mithious said:


        // 100 lines of standard stuff that doesn't use j and fits really well into a separate function

     

    What? This one displays fine on my phone. There are other terrible code examples on this site that doesn't. If it's legible on a 4.x" screen it should be done on a desktop monitor. Unless you're as blind as a bat and use 200% page zoom on a 24" 1280×800?

    I'm with him on this one. On Safari the code quoted by the OP does not wrap, and in fact truncates it if the browser is narrower than that text. So even though I do get scrollbars when I make the window narrow, the scrollbars .. they do nothing.



  • @OzPeter said:

    @Zemm said:
    @AndyCanfield said:

    @Mithious said:


        // 100 lines of standard stuff that doesn't use j and fits really well into a separate function

     

    What? This one displays fine on my phone. There are other terrible code examples on this site that doesn't. If it's legible on a 4.x" screen it should be done on a desktop monitor. Unless you're as blind as a bat and use 200% page zoom on a 24" 1280×800?

    I'm with him on this one. On Safari the code quoted by the OP does not wrap, and in fact truncates it if the browser is narrower than that text. So even though I do get scrollbars when I make the window narrow, the scrollbars .. they do nothing.

    Maybe you guys should blame your browsers' implementation of the PRE tag. Or just use a monitor that has more than 80px of screen width. If you're using anything smaller than 1920x1080 in this day and age, you should be ashamed of yourself.



  • @The_Assimilator said:

    If you're using anything smaller than 1920x1080 in this day and age, you should be ashamed of yourself.
     

    HAHAHAHAHAHAHAHA

    You're an asshole. That's okay, but you gotta know it.

    1920 pixels wide is completely unusable and I don't understand how you guys do it.

    In addition, this is the OP so I have no idea what you guys are talking about with "long lines".



  • @dhromed said:

    @The_Assimilator said:

    If you're using anything smaller than 1920x1080 in this day and age, you should be ashamed of yourself.
     

    HAHAHAHAHAHAHAHA

    You're an asshole. That's okay, but you gotta know it.

    I wasn't aware that my assholery was ever in doubt.



  • @The_Assimilator said:

    I wasn't aware that my assholery was ever in doubt.
     

    That is a good point.

    Anyway, I'm on 1200 wide (work)  and 1360 wide (home). (I'd love to go a bit higher at home, but my CRT's mask's dot pitch isn't quite up to it. 1600x1200 looks like a downsampled image*.)

     

    *) Good for gaming though. I usually get away with 2x2 AA, and just up the resomolution, which is cheaper in terms of GPU.


  • ♿ (Parody)

    @dhromed said:

    1920 pixels wide is completely unusable and I don't understand how you guys do it.

    Yep. I don't horizontally maximize my browser for normal reading either.



  • @AndyCanfield said:

    Am I poor white trash, or do you guys on thedailyWTF all have monitors that are six feet wide and display five thousand pixels?


    I wonder whether you have a user style imposing a sensible font size on the code snippet. I see <pre> content as 10px text on TDWTF forums (except in preview, where it's a more readable 12px), so the line you quoted is less than 600px wide for me.


  • Discourse touched me in a no-no place

    @The_Assimilator said:

    @OzPeter said:
    @Zemm said:
    @AndyCanfield said:

    @Mithious said:


        // 100 lines of standard stuff that doesn't use j and fits really well into a separate function

     

    What? This one displays fine on my phone. There are other terrible code examples on this site that doesn't. If it's legible on a 4.x" screen it should be done on a desktop monitor. Unless you're as blind as a bat and use 200% page zoom on a 24" 1280×800?

    I'm with him on this one. On Safari the code quoted by the OP does not wrap, and in fact truncates it if the browser is narrower than that text. So even though I do get scrollbars when I make the window narrow, the scrollbars .. they do nothing.

    Maybe you guys should blame your browsers' implementation of the PRE tag. Or just use a monitor that has more than 80px of screen width. If you're using anything smaller than 1920x1080 in this day and age, you should be ashamed of yourself.

    Or maybe, as usual, Community Server is TRWTF. Chrome truncates the text if you narrow the window to be narrower than the longest line of that code snippet.



  • @dhromed said:

    Anyway, I'm on 1200 wide (work)  and 1360 wide (home). (I'd love to go a bit higher at home, but my CRT's mask's dot pitch isn't quite up to it. 1600x1200 looks like a downsampled image*.)

    Why are you using a CRT? The only reason I can think of to still use a CRT is better colours if you do video or photo-editing or something, but if it's crappy that it cannot properly handle 1600x1200 then a good TFT will probably be better...



  • @The_Assimilator said:

    Maybe you guys should blame your browsers' implementation of the PRE tag.
    Most of the time, text wraps OK, but sometimes a combination of Community Server and/or Firefox WTFs results in something like this:



  • @dhromed said:

    @The_Assimilator said:

    I wasn't aware that my assholery was ever in doubt.
     

    That is a good point.

    If it is ever in doubt, please notify me promptly so that I may rectify the situation.

    @dhromed said:

    Anyway, I'm on 1200 wide (work)  and 1360 wide (home). (I'd love to go a bit higher at home, but my CRT's mask's dot pitch isn't quite up to it. 1600x1200 looks like a downsampled image*.)

     

    *) Good for gaming though. I usually get away with 2x2 AA, and just up the resomolution, which is cheaper in terms of GPU.

    A CRT monitor? In 2013? Do you hate yourself? Or has the radiation conditioned you to believe that CRTs are the One True Way?

    I roll with twin 1920x1080 displays at work (we're only allowed to have 1 each but FUCK THA POLICE) and would add a third if I could (3240x1920 in portrait mode, hells yes). One can never have too much screen real estate.



  • @FrostCat said:

    @The_Assimilator said:
    @OzPeter said:
    @Zemm said:
    @AndyCanfield said:

    @Mithious said:


        // 100 lines of standard stuff that doesn't use j and fits really well into a separate function

     

    What? This one displays fine on my phone. There are other terrible code examples on this site that doesn't. If it's legible on a 4.x" screen it should be done on a desktop monitor. Unless you're as blind as a bat and use 200% page zoom on a 24" 1280×800?

    I'm with him on this one. On Safari the code quoted by the OP does not wrap, and in fact truncates it if the browser is narrower than that text. So even though I do get scrollbars when I make the window narrow, the scrollbars .. they do nothing.

    Maybe you guys should blame your browsers' implementation of the PRE tag. Or just use a monitor that has more than 80px of screen width. If you're using anything smaller than 1920x1080 in this day and age, you should be ashamed of yourself.

    Or maybe, as usual, Community Server is TRWTF. Chrome truncates the text if you narrow the window to be narrower than the longest line of that code snippet.

    http://forums.thedailywtf.com/themes/leanandgreen/style/forum.css

    ^FForumPostBodyArea





  • @Ben L. said:

    HEY GUYS I FIXED IT

    Couldn't you just stick that in an open tag in a signature guy and fix it for everyone?



  • @dtech said:

    Why are you using a CRT?
     

    Excellent question! No really, it's an old piece of tech, so that's a good question.

    The answer is that it's not broken or defective. I've been predicting its demise (or sub-threshold performance) for the past 4 years but it just won't fucking happen. I really want an LP2056 to replace it, but the thing's hard to get.

    @dtech said:

    The only reason I can think of to still use a CRT is better colours if you do video or photo-editin

    Not at all. Any IPS or LED will have great colors. MVA I don't know. The CRT still beats any TN-panel, though. TN is shit, even compared to 20 year old tech.

    @dtech said:

    if it's crappy that it cannot properly handle 1600x1200 then a good TFT will probably be better...

    It's 19". Not even the Trinitron that was my previous one at work could actually display 1600*1200 fully (but I did it anyway lol).

    If you find me working on a 16:9 or thereabouts monitor, know that I have become a broken man who has given up on his dreams.



  • @The_Assimilator said:

    (3240x1920 in portrait mode, hells yes).
     

    Absolutely. That's why I have the 1600x1200 in portrait (I keep repeating myself). Won't the monitor edges in the middle fuck you over? You can't properly work with 1080 wide for a window. 1200 is good.

    I have a 1080p on the side for email and source control. I can't work on it.

    @The_Assimilator said:

    Do you hate yourself?

    Yes.

    @The_Assimilator said:

    One can never have too much screen real estate.

    Sure. Meanwhile, I'm using every pixel of my screen, while my coworkers have the right half of their idiot monitors completely blank because code doesn't go that far, and they firebug through letterboxes while I see everything comfortably.

     

     



  •  @OzPeter said:

    @Zemm said:
    @AndyCanfield said:

    @Mithious said:


        // 100 lines of standard stuff that doesn't use j and fits really well into a separate function

     

    What? This one displays fine on my phone. There are other terrible code examples on this site that doesn't. If it's legible on a 4.x" screen it should be done on a desktop monitor. Unless you're as blind as a bat and use 200% page zoom on a 24" 1280×800?

    I'm with him on this one. On Safari the code quoted by the OP does not wrap, and in fact truncates it if the browser is narrower than that text. So even though I do get scrollbars when I make the window narrow, the scrollbars .. they do nothing.

     

    FireFox does the same.  I get a scrollbar at the bottom of the screen, but not for the display area.

     



  • @dhromed said:

    Any IPS or LED will have great colors. MVA I don't know.
    I've got an S-IPS and S-PVA panels here, and I find the colours on S-PVA better than on S-IPS (not to mention blacks, which are grey on my IPS, at least compared to the screen next to it). Of course, my monitors are fairly old by now (4 and 7 years), so it's possible that newer iterations are better.



  • @ender said:

    blacks, which are grey on my IPS
     

    Can't explain that. I've also never had a VA panel. My work monitor is perfectly black, and it's 5 years old. I guess one IPS isn't the other?



  • @dhromed said:

    @dtech said:

    The only reason I can think of to still use a CRT is better colours if you do video or photo-editin

    Not at all. Any IPS or LED will have great colors. MVA I don't know. The CRT still beats any TN-panel, though. TN is shit, even compared to 20 year old tech.

    TN is shit of course, but very good (e.g. > $1000 at the time) CRT monitors still beat almost all LCD's (including the >$1000's of now) on colour. 3 years ago the graphics department of a company I worked for still had a few hooked up to do a final colour-check before the first sample printing.

    @dhromed said:
    If you find me working on a 16:9 or thereabouts monitor, know that I have become a broken man who has given up on his dreams.

    Try 16:10 1920x1200. I have 2 Dell Ultrasharp U2412M's and can't live without them.
    16:9 isn't the best for PC's because of the low vertical resolution/space, but 16:10 is a nice middle ground. Plus it is handy that placing two windows side-by-side is more often usable than on 4:3/5:4



  • @dtech said:

    Try 16:10 1920x1200. I have 2 Dell Ultrasharp U2412M's and can't live without them.
     

    Oh wow. And that price!

    I kept getting sadder and sadder every time I went window shopping for a new monitor, but you've given me hope.

     



  • @The_Assimilator said:

    One can never have too much screen real estate.
    Yeah, but it'll be easier to lose your Office menus if you move them away from the top of the window.


  • :belt_onion:

    @AndyCanfield said:

    - Po' Boy in Bangkok.

    Po' boys are delicious.


Log in to reply