Tabs > Spaces, and other fundamental truths :-D



  • I'm in the mood to troll some of my co-workers. Things have been a little tense, and I think this will lighten up the mood nicely :trollface:

    But I can't think of lots of trollbait topics like the tabs vs spaces one. I need some help here.

    What's a few hot button topics?

    • Tried Vim vs Emacs, but they didn't know what either was :facepalm:
    • Comments vs Self Documenting code


  • Wear one of this in the office.


  • SockDev

    Braces or no braces for code like this:

    if (condition)
        taskOne();
    else
        taskTwo();
    

    Also brace style; those two are almost guaranteed to generate a lot of 'debate' ;)



  • I quite like that one :joy:

    Also, since we've inherited code with this little anti-pattern sprinkled randomly...

    if (condition) { taskOne(); } else {taskTwo(); }
    

    It also ought to spark some debate :smile:


  • area_deu

    Early returns.


  • Discourse touched me in a no-no place

    • HTML/CSS is(n't) programming
    • Open/Closed source
    • Real programmers use $LANGUAGE, $OTHER_LANGUAGE is only a toy.
    • $SHELL is better than $OTHER_SHELL
    • CLI/GUI is better for $STUFF
    • camelCase/PascalCase/snake_case/StUdLyCaPs
    • KDE/GNOME
    • $BROWSER1 vs $BROWSER2
    • Apps vs System Hungarian.
    • OO Models should(n't) closely match real world objects
    • Multiple inheritance, discuss
    • Function length - how big is a page?
    • Star Trek vs Star Wars.

  • Winner of the 2016 Presidential Election

    What is their opinion on Desktop Search for the masses? Bonus points if you can call them clueless and super bonus points if you can sell them on the idea :trollface:

    Write some code in abbreviated MUMPS and ask your :cow:workers to help you find the error.

    Filed Under: At the end of the day, their mood will lighten up because they don't have to deal with your trolling anymore! Win:Win-Situation!


  • SockDev

    @PJH said:

    StUdLyCaPs

    Anyone who I see using this style will meet the business end of this:


  • BINNED

    @PJH said:

    Function length - how big is a page?

    • more than 80 columns in a file


  • One of the guys here constantly says that Linux is better than Windows because [insert arbitrary reason here]

    And then he goes on this little Linux evangelising stint. But I've been able to trace every single Windows complaint of his to (admittedly draconian) group policies set here by the admins. So not really representative of a home use OS...

    Lately I've noticed how he doesn't like it when I "defend" Windows here :stuck_out_tongue:


  • BINNED

    @AgentDenton said:

    But I've been able to trace every single Windows complaint of his to (admittedly draconian) group policies set here by the admins. So not really representative of a home use OS...

    I got a whole list already from using Win10 for like 10 hours total, but pointing them out would probably just end up with everyone telling me I'm :doing_it_wrong:


    Filed under: [Who puts the taskbar on the top oh their screen, really!] (#click-to-break-discourse), :trolleybus:



    • "ternary operators"?good:bad;
    • Mac or Windows
    • Windows phones
    • Agile
    • CMMI
    • Casually drop the statement that I always store my program settings in %USERPROFILE%"My Documents" -- it is the only reliable way to decide where files should be located in Windows.

  • SockDev

    @RaceProUK said:

    if (condition)
    taskOne();
    else
    taskTwo();

    no, no no!

    this is how you do it!

    def doit():
        task = taskTwo
        if condition:
            task = taskOne
        task()
    


  • @PJH said:

    Multiple inheritance, discuss

    Composition > inheritance.

    (except when not)


  • SockDev

    @AgentDenton said:

    if (condition) { taskOne(); } else {taskTwo(); }

    what insanity is this?

    try this instead!

    (condition ? taskOne : taskTwo)()
    


  • var response = true;

    var condition = getCondition(bool invertResult);
    if (!condition) taskOne();
    else {
       taskTwo();
       return invertResult ? false : response;
    }
    
    return response;

  • SockDev

    E_PARSE_ERROR return is not valid outside of function scope.


  • BINNED

    Amateurs.

    function task_1() { ... }
    function task_2() { ... }
    
    call_user_func("task_".(1 + intval(<condition>)));
    

    There! Brillant!


    Filed under: INB4 @Arantor posts actual production code doing this



  • I didn't want the method furniture to detract from the beauty of the code


  • SockDev

    @Onyx said:

    call_user_func("task_".(1 + intval(<condition>)));

    #E_


  • SockDev

    @skotl said:

    I didn't want the method furniture to detract from the beauty of the code

    you prefer compiler errors to do taht afor you?



  • [taskOne, taskTwo][ condition ? 0: 1]
    

  • SockDev

    @accalia said:

    @RaceProUK said:
    if (condition)
    taskOne();
    else
    taskTwo();

    no, no no!

    this is how you do it!

    def doit():
        task = taskTwo
        if condition:
            task = taskOne
        task()
    ```</blockquote>
    
    https://www.youtube.com/watch?v=ZXsQAXx_ao0
    :question:

  • BINNED

    You called for insanity. You got a PHP dev.

    Be careful what you wish for.

    :stuck_out_tongue:



  • I've actually used that pattern once or twice in Lua code.


  • SockDev

    @RaceProUK said:

    :question:

    that works... :stuck_out_tongue:

    i was thinking more like "eeh i don't know what to call the function so i'll call it doit"


  • SockDev

    @Onyx said:

    Be careful what you wish for.

    caveat emptor indeed.....



  • Did you mean

    If (condition) task1(); else { Task2() }

  • Discourse touched me in a no-no place

    @Mikael_Svahnberg said:

    "ternary operators"?good:bad;

    @PJH said:

    @Tyler said:
    ```
    std::cout << "Good morning " << ((gender == Male) ? "Sir" : "Ma'am") << std::endl;

    
    I do, however have issues with things like:
    <code><pre>
    		syslog(LOG_NOTICE, "WebRelay %s:%d Relay: %s Input: %s Reboot: %s",
    			inet_ntoa(sin->sin_addr.s_addr), ntohs(sin->sin_port),         
    			relay  == 0 ? "on" : "off",                                    
    			input  == 1 ? "on" : "off",                                    
    			reboot == 0 ? "Auto Reboot off" :                              
    			reboot == 1 ? "Pinging" :                                      
    			reboot == 2 ? "Waiting for response" :                         
    			reboot == 3 ? "Rebooting" :                                    
    			reboot == 4 ? "Waiting for reboot" :                           
    				      "Unknown"                                            
    			);
    </pre>
    </code></blockquote>
    
    
    ... and I keep meaning to find the deleted code in SVN where someone nested ternary operators. Even worse than that.

  • SockDev

    @PJH said:

    nested ternary operators

    I've done that before, but I never go more than two deep when I do.

    :giggity‍:



  • So gender binary...


  • BINNED



  • Tabs vs. Spaces vs. Zero-width non-joiners vs. line feeds vs. NUL vs. non-breaking spaces.


  • Discourse touched me in a no-no place

    @PJH said:

    ... and I keep meaning to find the deleted code in SVN where someone nested ternary operators. Even worse than that.

    Went back as recent as 2008 (after I started, so should have been there) and couldn't find what I thought I remembered. More examples, however:

            if      (icla1 == NULL || icla2 == NULL || iclbc == NULL)
            {       syslog(LOG_ERR, "exiting %s%s%s undefined",
                            icla1 ? icl_relay2 : icla2 ? icl_relay1 : "Both icl_relays",
                            iclbc ? "" : icla1 == NULL || icla2 == NULL ? " and " : "",
                            iclbc ? "" : icl_broadcast
                    );
                    exit(1);
            }
    
                    syslog(LOG_NOTICE, "%s completed: %s", cmd,
                                    rc == 0      ?  "Success" :
                                    rc == 1      ?  "Syntax or usage error" :
                                    rc == 2      ?  "Protocol incompatibility" :
                                    rc == 3      ?  "Errors selecting input/output files, dirs" :
                                    rc == 4      ?  "Action not supported" :
                                    rc == 5      ?  "Error starting client-server protocol" :
                                    rc == 6      ?  "Daemon unable to append to log-file" :
                                    rc == 10     ?  "Error in socket I/O" :
                                    rc == 11     ?  "Error in file I/O" :
                                    rc == 12     ?  "Error in rsync protocol data stream" :
                                    rc == 13     ?  "Errors with program diagnostics" :
                                    rc == 14     ?  "Error in IPC code" :
                                    rc == 20     ?  "Received SIGUSR1 or SIGINT" :
                                    rc == 21     ?  "Some error returned by waitpid()" :
                                    rc == 22     ?  "Error allocating core memory buffers" :
                                    rc == 23     ?  "Partial transfer due to error" :
                                    rc == 24     ?  "Partial transfer due to vanished source files" :
                                    rc == 25     ?  "The --max-delete limit stopped deletions" :
                                    rc == 30     ?  "Timeout in data send/receive" :
                                                    "Unknown Error"
                            );
    

  • SockDev

    @PJH said:

    ```
    syslog(LOG_NOTICE, "%s completed: %s", cmd,
    rc == 0 ? "Success" :
    rc == 1 ? "Syntax or usage error" :
    rc == 2 ? "Protocol incompatibility" :
    rc == 3 ? "Errors selecting input/output files, dirs" :
    rc == 4 ? "Action not supported" :
    rc == 5 ? "Error starting client-server protocol" :
    rc == 6 ? "Daemon unable to append to log-file" :
    rc == 10 ? "Error in socket I/O" :
    rc == 11 ? "Error in file I/O" :
    rc == 12 ? "Error in rsync protocol data stream" :
    rc == 13 ? "Errors with program diagnostics" :
    rc == 14 ? "Error in IPC code" :
    rc == 20 ? "Received SIGUSR1 or SIGINT" :
    rc == 21 ? "Some error returned by waitpid()" :
    rc == 22 ? "Error allocating core memory buffers" :
    rc == 23 ? "Partial transfer due to error" :
    rc == 24 ? "Partial transfer due to vanished source files" :
    rc == 25 ? "The --max-delete limit stopped deletions" :
    rc == 30 ? "Timeout in data send/receive" :
    "Unknown Error"
    );

    
    Whoever wrote that needs beating with one of these:
    <img src="/uploads/default/original/3X/8/e/8edbe7c0ec65e3efc5577358c5a9b96b30fe4223.png" width="250" height="250">

  • Discourse touched me in a no-no place

    @RaceProUK said:

    Whoever wrote that needs beating with one of these:

    Might have sobered him up... (while I may joke about getting drunk, I don't do it (or turn up) at work in that state - he apparently did, on a regular basis. I only heard the rumours - I never actually met him.)



  • Okay, that's quite a huge nested ternary there. We've also got a few, not quite as deep, but without line breaks. And f*ck does that make it extremely difficult to troubleshoot.

    A critical call comes in and it's not uncommon for us to say something like "I'm still deciphering the code here", which means the troubleshoot-er is just adding line breaks and indents to

    • Single line ternaries
    • Single line complex Linq queries
    • Single line if else block

    Hmmm... there's a pattern emerging here... :sob:


  • Winner of the 2016 Presidential Election

    Sorry, but no!

    That switch does not have a flippable switch on the switch which in turn has a switch that can be flipped to activate another switchable flipflippable switch

    Filed Under: The thing you would have to beat him with would consist of ~200 switches piled on top of each other. Weighting a grand total of ~300 pounds.


  • SockDev

    Also, #switchception is a Twitter hashtag for some raisin :\


  • Winner of the 2016 Presidential Election

    [image src="RandomDude" Caption="A question inside a question inside a question? Everyday stuff for a person fiddeling around with tenary operators"]

    Filed Under: :lazy:



  • @PJH said:

    HTML/CSS is(n't) programming

    This.


  • Discourse touched me in a no-no place

    @cartman82 said:

    @PJH said:
    HTML/CSS is(n't) programming

    This.

    The case for: FizzBuzz in CSS. [mod - this was for Discourse, not NodeBB - @PJH]

    The case against - how it was done:

    table.ember-view.topic-list tbody tr:nth-child(2n+1),
    table.ember-view.topic-list tbody tr:nth-child(2n) {
    background-color: initial;
    }
    table.ember-view.topic-list tbody tr:nth-child(3n) {
      background-color: #f00;
    }
    table.ember-view.topic-list tbody tr:nth-child(5n) {
      background-color: #0f0;
    }
    table.ember-view.topic-list tbody tr:nth-child(15n) {
      background-color: #ff0;
    }
    

  • Winner of the 2016 Presidential Election

    FizzBuzz isn't programming. It's a test during an iterview!

    Filed Under: How many times did you have to program fizzbuzz after you have been employed, huh?
    Also Filed Under: In case it wasn't clear: :trollface:


  • Discourse touched me in a no-no place

    @Kuro said:

    How many times did you have to program fizzbuzz after you have been employed, huh?

    In my current job?

    Once so far, but that was on here, not for work, and it was that link...



  • @Mikael_Svahnberg said:

    Casually drop the statement that I always store my program settings in %USERPROFILE%"My Documents" -- it is the only reliable way to decide where files should be located in Windows.
    If I could stab you over the internet. :knife:



  • @accalia said:

    @RaceProUK said:
    if (condition)
    taskOne();
    else
    taskTwo();

    no, no no!

    this is how you do it!

    def doit():
        task = taskTwo
        if condition:
            task = taskOne
        task()
    ```</blockquote>
    
    How about?
    
    

    if (condition)
    taskOne();
    else if (!condition)
    taskTwo();



  • @Onyx said:

    You calledasked for insanity, Theo. You gotI give you a PHP dev.

    DHTFY



  • @accalia said:

    ```
    def doit():
    task = taskTwo
    if condition:
    task = taskOne
    task()

    
    I was going to say:
    
    ```clojure
    ((if condition task-one task-two))
    

  • Winner of the 2016 Presidential Election

    @RaceProUK said:

    Also brace style

    Try to argue for the GNU brace style to offend everyone equally!

    Also, tell every VIM user that they should use a proper IDE instead.


  • Discourse touched me in a no-no place

    @Onyx said:

    more than 80 columns in a file

    my 1080 monitor just spit in your eye.


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.