New Programming Jargon - thanks to Stack Overflow and Coding Horror...

Started by Mr. Analog, April 04, 2017, 12:58:33 PM

Previous topic - Next topic

Mr. Analog

QuoteStack Overflow ? like most online communities I've studied ? naturally trends toward increased strictness over time. It's primarily a defense mechanism, an immune system of the sort a child develops after first entering school or daycare and being exposed to the wide, wide world of everyday sneezes and coughs with the occasional meningitis outbreak. It isn't always a pleasant process, but it is, unfortunately, a necessary one if you want to survive.

https://blog.codinghorror.com/new-programming-jargon/

To get you started:

Quote1. Yoda Conditions

Using if(constant == variable) instead of if(variable == constant), like if(4 == foo). Because it's like saying "if blue is the sky" or "if tall is the man".

Ahhhh good stuff....
By Grabthar's Hammer

Thorin

As a coder I understand the reasoning behind Yoda Conditions (reduces chance you forget an equals sign and cause a bug where the variable is assigned the value rather than compared to the value).  Years poring over code in maintenance, though, has shown me just how horrible this is to read; it never flows nicely and I'm always tripping up over it.  At the same time, my brain is quite good at quickly spotting a missing equals sign.
Prayin' for a 20!

gcc thorin.c -pedantic -o Thorin
compile successful

Lazybones

I always read if( x == y) as "if x and y are the same". No yoda phrasing needed.

Darren Dirt

Quote from: Mr. Analog on April 04, 2017, 12:58:33 PM
Stack Overflow ? like most online communities I've studied ? naturally trends toward increased strictness over time.

Oh crap, I "caused" this thread didn't I?




Quote from: Mr. Analog on April 04, 2017, 12:58:33 PM
To get you started:

Quote1. Yoda Conditions

Using if(constant == variable) instead of if(variable == constant), like if(4 == foo). Because it's like saying "if blue is the sky" or "if tall is the man".


No joke I actually DO make a habit of doing this in virtually every situation possible, just because it is incredibly clear that you are checking equality of two values, not setting it (esp. helpful in non-JS/Java languages like VBS/VBA etc... which is when I started to make it a habit. Also I have trained myself to use "===" in JavaScript unless I actually intend to only check "==" equality which is of course extremely rare. And yet despite these habits of mine I still think Douglas Crockford and his arbitrary strictrulesness can go take a long walk off a short pier, for the most part...)
_____________________

Strive for progress. Not perfection.
_____________________

Thorin

if ( testResult.GroupPath[0].GroupName == "US" ) { }
vs
if ( "US" == testResult.GroupPath[0].GroupName ) { }

I find the first doesn't require me to stop and think about it at all, whereas the second, I need to stop for a split second and say, what are we comparing again?  Oh yeah, the first group name to see if it's "US".

Maybe it's because I subconsciously ignore most of the variable and so just see the two things closest to the equals equals, so I subconsciously see GroupName == "US" or "US" == testResult.
Prayin' for a 20!

gcc thorin.c -pedantic -o Thorin
compile successful

Mr. Analog

My fave will always be:

LogicallyBigThing < LogicallySmallThing

There's just something unsettling about it
By Grabthar's Hammer

Darren Dirt

Quote from: Thorin on April 04, 2017, 02:18:47 PM
if ( testResult.GroupPath[0].GroupName == "US" ) { }
vs
if ( "US" == testResult.GroupPath[0].GroupName ) { }

I find the first doesn't require me to stop and think about it at all, whereas the second, I need to stop for a split second and say, what are we comparing again?  Oh yeah, the first group name to see if it's "US".

Maybe it's because I subconsciously ignore most of the variable and so just see the two things closest to the equals equals, so I subconsciously see GroupName == "US" or "US" == testResult.

Seriously my brain reads these syntactical structures as "IF (left part) is the value of (right part)" just as fast as it USED to read "IF (left part) is equal to (right part)". Didn't even take that much work to change. Brains have a funny ability to adapt to new habits.




Quote from: Mr. Analog on April 04, 2017, 02:22:02 PM
My fave will always be:

LogicallyBigThing < LogicallySmallThing

There's just something unsettling about it
+1000 for that, though, dude! Always fun/funny when a "min/max" logical elements allows for negative numbers and whatnot and does some kind of sorting/looping with those values and you end up having some line of code that has that kind of "opposite" appearing tone to it, gotta write it out on paper to make sure it is correct sometimes :P
_____________________

Strive for progress. Not perfection.
_____________________

Lazybones

If we want to complain about if logic why not talk about the various ways different languages treat NULL values or even empty strings.. If NOT isNULL(X)

Thorin

Quote from: Lazybones on April 04, 2017, 02:53:39 PM
If we want to complain about if logic why not talk about the various ways different languages treat NULL values or even empty strings.. If NOT isNULL(X)

Goddamn Oracle, don't replace my empty string with a null value!  http://stackoverflow.com/questions/13278773/null-vs-empty-string-in-oracle
Prayin' for a 20!

gcc thorin.c -pedantic -o Thorin
compile successful

Mr. Analog

Ahh that's one of the best first things I ever learnt: null and not allocated can be two different things depending on the language

Also some languages have no concept of "unassigned" like the .NET framework, everything is an object instance, which can lead to some fun if you aren't paying attention

So

var x = 5;
var y = 5;

x and y are two unique instances of the Int(32) object HOWEVER when you compare them using == they evaluate to be equivalent, this is because nobody would ever think that 5 == 5 is not really equal under the hood. In fact one of the problems with earlier versions of the framework was when you compared values of "base" object instances the runtime would completely ignore the declared type and treat it as the contextually implied type which is fun if you have a case statement or actually take advantage of polymorphism

But I mean who would do a crazy thing like:

DoTheMath(int thing);
DoTheMath(long morePreciseThing);

T-That's crazy talk!




Speak of the devil... oh JavaScript I love you

if (data !== null)
By Grabthar's Hammer

Darren Dirt

What about languages that treat "0" as equivalent to 0... yeehaw!
_____________________

Strive for progress. Not perfection.
_____________________

Darren Dirt

 By the way, the Oracle NULLstring weirdness diverging from SQL92 standard is apparently because Oracle DB pre-dates SQL92... but might change VARCHAR in the future (which is why devs use VARCHAR2 for its predictable-but-asinine behavior). Post-92 they didn't adapt because it would break lotsa code I guess:

http://stackoverflow.com/questions/203493/why-does-oracle-9i-treat-an-empty-string-as-null


I wonder, do ANY long-term Oracle DBAs still have hair left? https://jeffkemponoracle.com/2012/09/03/top-10-confusing-things-in-oracle/ MADNESS!
_____________________

Strive for progress. Not perfection.
_____________________

Darren Dirt

I guess the original "question" was deleted because it ain't what Stack Overflow is all about.

But it's sorta still available (with lots more "answers" than just Jeff's Top30) here: http://www.stackprinter.com/questions/new-programming-jargon-you-coined.html
_____________________

Strive for progress. Not perfection.
_____________________