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
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
- Comments vs Self Documenting code
-
Wear one of this in the office.
-
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
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
-
Early returns.
-
- 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.
-
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
Write some code in abbreviated MUMPS and ask your workers to help you find the error.
-
-
-
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
-
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
Filed under: [Who puts the taskbar on the top oh their screen, really!] (#click-to-break-discourse),
-
- "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.
-
if (condition)
taskOne();
else
taskTwo();no, no no!
this is how you do it!
def doit(): task = taskTwo if condition: task = taskOne task()
-
-
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;
-
E_PARSE_ERROR
return
is not valid outside of function scope.
-
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
-
-
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]
-
@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:
-
You called for insanity. You got a PHP dev.
Be careful what you wish for.
-
I've actually used that pattern once or twice in Lua code.
-
that works...
i was thinking more like "eeh i don't know what to call the function so i'll call it
doit
"
-
-
Did you mean
If (condition) task1(); else { Task2() }
-
"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.
-
nested ternary operators
I've done that before, but I never go more than two deep when I do.:giggityβ:
-
So gender binary...
-
Pfft!
https://what.thedailywtf.com/t/status-status-thread-flatulence/1673/13763?u=onyx
There we go, a proper one.
-
Tabs vs. Spaces vs. Zero-width non-joiners vs. line feeds vs.
NUL
vs. non-breaking spaces.
-
... 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" );
-
```
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">
-
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...
-
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
-
Also, #switchception is a Twitter hashtag for some raisin :\
-
[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.
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; }
-
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:
-
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...
-
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.
-
@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();
-
-
```
def doit():
task = taskTwo
if condition:
task = taskOne
task()I was going to say: ```clojure ((if condition task-one task-two))
-
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.
-