lengau ยท 11 points ยท Posted at 12:00:32 on June 10, 2016 ยท (Permalink)
I had a code reviewer at a previous job who always wanted me to change if X is None to if not x. Which I get if you're actually looking for a falsy value, but not when you specify that the variable is a tristate with possible values of True, False, and None.
Unless you want your block to run in any case where X != True, because False != None (at least not in python)
lengau ยท 3 points ยท Posted at 17:30:56 on June 10, 2016 ยท (Permalink)
Correct, which is what I did in several other places, but this particular guy pretty much always suggested changing 'if x is None' to 'if not x', even in cases where this changed the behaviour of the program.
Another such example was an optional list with a default value. Something like this:
def fun(a, opt=None):
if opt is None:
opt = ['blah', 'blah', 'blah', 42]
# do stuff including mutating opt
This is fine to replace with if not opt if you're either never expecting an empty list or are expecting one but want to replace it with the default list, but in this case the same commit included a call of fun(x, opt=[]) which would have broken things had opt been replaced with the default.
I have actually seen this somewhere with an extra comment that makes it even crazier:
if (x)
return true;
// Check again just in case x changed value in the meantime.
else if (!x)
return false;
And before you ask, this was a single-threaded application with no hardware/DMA interactions. x wasn't even marked as volatile. I have no idea what was the intention.
cg2916 ยท 1 points ยท Posted at 17:28:29 on June 10, 2016 ยท (Permalink)
LMAO. Clearly he was worried about a bit flip in the memory, gotta be doubly sure.
lx45803 ยท 6 points ยท Posted at 00:36:47 on June 10, 2016 ยท (Permalink)
I wonder if your typical compiler is smart enough to optimize that out. I mean, most optimizations target the weird tricky stuff, not the kind of thing a 5th grader can figure out.
flip314 ยท 13 points ยท Posted at 01:21:38 on June 10, 2016 ยท (Permalink)
Short answer: yes.
Long answer: there might be some funny stuff if x is declared as volatile, but I'm not even sure about that since it's all in one expression.
Also, most compiler optimizations target really obvious stuff.
Would the compiler recognize it if you're in a language where operator overrides are allowed, and the ">" operator has been overridden? Because if not, the value of x could change after each evaluation.
I'm very okay with this, because I dislike using implicit falseyness. I feel like it's too likely for me to run afoul of some obscure rule I don't know about yet, and makes my code harder to read.
devdot ยท 4 points ยท Posted at 13:11:13 on June 10, 2016 ยท (Permalink)
Exactly. I always use either isset, empty and != "" because it's more obvious what should happen. I don't give a shit about writing haxxor uber code in PHP, PHP syntax not safe enough to do that. PHP doesn't have C/C++ type of syntax and backwards compatibility thereof.
Optimization is good though, but I seriously doubt using isset, empty etc will have a big impact on your applications performance.
I haven't done PHP in a long while (mostly c# for the moment) but there's a lot of people that want to do weird shit in c# as well because it's "optimized".
There are lots of ways to legitly optimize your code and they chose to fuck up their if/else blocks and other shit.
How is 'if ($value != "")' easier to read than 'if ($value)'? What level of coder are you exactly "optimising readability" for that doesn't know the two are the same? Alternatively, what application are you writing where the distinction between null and an empty string really matters?
I actively keep an eye open for redundancy when I'm programming. Developed the habit when I was learning Java. It's verbose enough without stuff like that everywhere.
I notice there's a gap between the top few points and the bottom ones - I wonder if it was supposed to be "required skills" as the top, and "desired skills" at the bottom, but they left out the line of text that explained that.
Edit: The top skills look like really baseline stuff - you basically just need experience in any OO language, plus all the web fundamentals of HTML etc - while the bottom stuff is more specific. I'm not even a web developer, and I satisfy most of the top criteria. But I don't really even know what REST and SOAP are...
devdot ยท 6 points ยท Posted at 13:17:27 on June 10, 2016 ยท (Permalink)
The guy who made this page probably had only 3+ years of experience.
I never understand the point of putting down things like "must be able to work in a fast paced environment" or "passion for building a rich and innovative user experience".
Are they really some applicants who read this and think
"Oh no, I was dreaming to work for them, but I am only able to work in a lazy-ass environment, and I only enjoy building poor and old school user experience. Oh well, I'll keep job hunting until I find the right one!"
๐๏ธ PDX_Bro ยท 11 points ยท Posted at 18:07:37 on June 9, 2016 ยท (Permalink)
This was found in this job listing on StackOverflow. No prefacing separations between these two requirements at all haha.
Looks like their hiring department may have a copy + paste issue...
A-Type ยท 2 points ยท Posted at 12:51:41 on June 10, 2016 ยท (Permalink)
I think you could parse it as
Experience developing AJAX interfaces with { AJAX libraries (<no examples given>) and [JavaScript] frameworks (<JavaScript framework examples given>) }
Either way I'm not sure what they mean by that, even as a fullstack dev. You want to know if I can... make AJAX requests from a JavaScript client? Define a client-server API? Roll my own AJAX tools?
SilasX ยท 3 points ยท Posted at 21:25:03 on June 9, 2016 ยท (Permalink)
That's a test of whether you can notice and simplify logical expressions, duh.
Darkitz ยท 4 points ยท Posted at 10:21:33 on June 10, 2016 ยท (Permalink)
i understand that companies want programming experience. Because when studying computerscience you learn jackshit about programming
8BitAce ยท 5 points ยท Posted at 11:03:38 on June 10, 2016 ยท (Permalink)
Well ya, CS isn't really about programming. That's just a component.
[deleted] ยท 5 points ยท Posted at 10:37:40 on June 10, 2016 ยท (Permalink)
Depends on the University, but overall I'd tend to agree. In four months at a software company I learned much more about programming than in 3 years studying CS.
Darkitz ยท 2 points ยท Posted at 12:52:48 on June 10, 2016 ยท (Permalink)
projectcontrolling, designbasics. hardwarestuff, documentation, uml. Ofcourse theres some java and c. pure c is only really 1/36 of a bachelors degree and java is about 5/36. webdevelopment: another 1/36.
If you like programming you better not study computerscience.
Saved comment
Salanmander ยท 156 points ยท Posted at 18:23:52 on June 9, 2016 ยท (Permalink)
The number of times I've seen student code with things like
if(x > 3 && x > 5)...OrrinH ยท 131 points ยท Posted at 22:36:10 on June 9, 2016 ยท (Permalink)
cg2916 ยท 103 points ยท Posted at 00:07:58 on June 10, 2016 ยท (Permalink)*
Or worse:
CounterShadowform ยท 76 points ยท Posted at 01:51:57 on June 10, 2016 ยท (Permalink)
walfracar ยท 59 points ยท Posted at 03:00:07 on June 10, 2016 ยท (Permalink)
Please make it stop
BinaryBagel ยท 41 points ยท Posted at 03:03:29 on June 10, 2016 ยท (Permalink)
return false;
SlumdogSkillionaire ยท 22 points ยท Posted at 04:13:15 on June 10, 2016 ยท (Permalink)
Because None is falsey.
lengau ยท 11 points ยท Posted at 12:00:32 on June 10, 2016 ยท (Permalink)
I had a code reviewer at a previous job who always wanted me to change
if X is Nonetoif not x. Which I get if you're actually looking for a falsy value, but not when you specify that the variable is a tristate with possible values of True, False, and None.Stoic_stone ยท 2 points ยท Posted at 14:28:14 on June 10, 2016 ยท (Permalink)
The whole job was code review?
lengau ยท 2 points ยท Posted at 15:21:35 on June 10, 2016 ยท (Permalink)
No, but when he was reviewing code, he was a code reviewer. When he was writing code, he was a developer and someone else was a code reviewer for him.
KronktheKronk ยท 1 points ยท Posted at 17:14:55 on June 10, 2016 ยท (Permalink)
Unless you want your block to run in any case where X != True, because False != None (at least not in python)
lengau ยท 3 points ยท Posted at 17:30:56 on June 10, 2016 ยท (Permalink)
Correct, which is what I did in several other places, but this particular guy pretty much always suggested changing 'if x is None' to 'if not x', even in cases where this changed the behaviour of the program.
Another such example was an optional list with a default value. Something like this:
This is fine to replace with
if not optif you're either never expecting an empty list or are expecting one but want to replace it with the default list, but in this case the same commit included a call offun(x, opt=[])which would have broken things hadoptbeen replaced with the default.Neo_Techni ยท 6 points ยท Posted at 03:26:29 on June 10, 2016 ยท (Permalink)
Name checks out
[deleted] ยท 5 points ยท Posted at 10:30:02 on June 10, 2016 ยท (Permalink)
I want to get off r/shittyprogramming's wild ride.
AlumiuN ยท 3 points ยท Posted at 04:39:03 on June 10, 2016 ยท (Permalink)
vomits profusely
bgsavage ยท 3 points ยท Posted at 14:07:58 on June 10, 2016 ยท (Permalink)
My favorite is if(!(x==true)) I've seen it so many times and it's not students, but hired professionals....
Vindicer ยท 22 points ยท Posted at 00:37:17 on June 10, 2016 ยท (Permalink)
Now I'm curious if the compiler would just be all:
"Imma fix this."
...and proceed to optimise it to what we all expect:
return x;
Magnnus ยท 13 points ยท Posted at 01:43:15 on June 10, 2016 ยท (Permalink)
Depends on the compiler, but it's an easy enough optimization that most will do.
ojii ยท 6 points ยท Posted at 02:36:58 on June 10, 2016 ยท (Permalink)
that needs an else clause, because what if neither of the if checks go through?
cg2916 ยท 5 points ยท Posted at 02:54:51 on June 10, 2016 ยท (Permalink)
That's part of the fun!
draconk ยท 1 points ยท Posted at 11:29:15 on June 10, 2016 ยท (Permalink)
well it could be null (also known as maybe on booleans)
Sean1708 ยท 1 points ยท Posted at 13:25:55 on June 10, 2016 ยท (Permalink)
What sort of weird language are you using where a boolean can be null?
draconk ยท 1 points ยท Posted at 13:27:24 on June 10, 2016 ยท (Permalink)
In java you can just do Boolean bool; and is null by default
LondonNoodles ยท 3 points ยท Posted at 13:53:36 on June 10, 2016 ยท (Permalink)
He said "language" not disease.
draconk ยท 1 points ยท Posted at 13:56:03 on June 10, 2016 ยท (Permalink)
Savage
[deleted] ยท 1 points ยท Posted at 18:13:33 on June 10, 2016 ยท (Permalink)
The fuck are you using the object type for? That's disgusting
VitulusAureus ยท 5 points ยท Posted at 15:22:57 on June 10, 2016 ยท (Permalink)
I have actually seen this somewhere with an extra comment that makes it even crazier:
And before you ask, this was a single-threaded application with no hardware/DMA interactions.
xwasn't even marked as volatile. I have no idea what was the intention.cg2916 ยท 1 points ยท Posted at 17:28:29 on June 10, 2016 ยท (Permalink)
LMAO. Clearly he was worried about a bit flip in the memory, gotta be doubly sure.
Markyparky56 ยท 3 points ยท Posted at 08:46:22 on June 10, 2016 ยท (Permalink)
Maybe they were considering checking for the quantum superstate.
ThePixelCoder ยท 2 points ยท Posted at 12:25:11 on June 10, 2016 ยท (Permalink)
This hurts.
MrMeltJr ยท 1 points ยท Posted at 07:52:28 on June 10, 2016 ยท (Permalink)
Take out the else so we can really make sure x isn't false. Gotta double check every time, just in case.
[deleted] ยท 3 points ยท Posted at 12:46:56 on June 10, 2016 ยท (Permalink)
Not gonna lie, I did that once.
KronktheKronk ยท 1 points ยท Posted at 17:15:57 on June 10, 2016 ยท (Permalink)
shame.... shame.....shame
Triapod ยท 2 points ยท Posted at 12:29:49 on June 10, 2016 ยท (Permalink)
Moshambi ยท 30 points ยท Posted at 04:07:20 on June 10, 2016 ยท (Permalink)
Dude today I saw this in some code I was working with:
if($timestamp >= $current && $timestamp <= $current)
Like wtf...i had to read it like 5 times to make sure I wasn't missing something.
JonnyRichter ยท 21 points ยท Posted at 04:32:15 on June 10, 2016 ยท (Permalink)
So... If time stamp equals current?
Moshambi ยท 30 points ยท Posted at 04:48:06 on June 10, 2016 ยท (Permalink)
Yeah that's what I got out of it too. I fuckin left it though cause who knows what it could fuck up.
2211abir ยท 12 points ยท Posted at 13:12:26 on June 10, 2016 ยท (Permalink)
You're a wise developer.
tastychicken ยท 7 points ยท Posted at 13:38:51 on June 10, 2016 ยท (Permalink)
If it works don't fix it.
lx45803 ยท 6 points ยท Posted at 00:36:47 on June 10, 2016 ยท (Permalink)
I wonder if your typical compiler is smart enough to optimize that out. I mean, most optimizations target the weird tricky stuff, not the kind of thing a 5th grader can figure out.
flip314 ยท 13 points ยท Posted at 01:21:38 on June 10, 2016 ยท (Permalink)
Short answer: yes.
Long answer: there might be some funny stuff if x is declared as volatile, but I'm not even sure about that since it's all in one expression.
Also, most compiler optimizations target really obvious stuff.
Salanmander ยท 2 points ยท Posted at 10:38:59 on June 10, 2016 ยท (Permalink)
Would the compiler recognize it if you're in a language where operator overrides are allowed, and the ">" operator has been overridden? Because if not, the value of x could change after each evaluation.
mallardtheduck ยท 3 points ยท Posted at 12:33:47 on June 10, 2016 ยท (Permalink)
Yes. Any decent compiler will have replaced the operator with the overloaded function call before applying optimisations.
penguinade ยท 5 points ยท Posted at 11:42:53 on June 10, 2016 ยท (Permalink)
They also love to use arrays. Especially N-dimensional arrays. LOTS OF THEM.
Buttons[0][0][1][2].Width == Buttons[0][0][1][3].Width;
Arancaytar ยท 3 points ยท Posted at 12:15:39 on June 10, 2016 ยท (Permalink)
This is just future proof in case 5 ever becomes smaller than 3.
Mistercheif ยท 1 points ยท Posted at 12:44:18 on June 10, 2016 ยท (Permalink)
#define 5 rand()
Neo_Techni ยท 5 points ยท Posted at 03:30:01 on June 10, 2016 ยท (Permalink)
I keep seeing
If($value != "")
Instead of
If($value)
On a site I work on.
Salanmander ยท 24 points ยท Posted at 10:37:20 on June 10, 2016 ยท (Permalink)
I'm very okay with this, because I dislike using implicit falseyness. I feel like it's too likely for me to run afoul of some obscure rule I don't know about yet, and makes my code harder to read.
teddy_beer_maniac ยท 14 points ยท Posted at 07:01:15 on June 10, 2016 ยท (Permalink)
It may be this way, because When converting to boolean, the following values are considered FALSE: the empty string, and the string "0".
devdot ยท 4 points ยท Posted at 13:11:13 on June 10, 2016 ยท (Permalink)
Exactly. I always use either
isset,emptyand!= ""because it's more obvious what should happen. I don't give a shit about writing haxxor uber code in PHP, PHP syntax not safe enough to do that. PHP doesn't have C/C++ type of syntax and backwards compatibility thereof.tastychicken ยท 1 points ยท Posted at 13:40:18 on June 10, 2016 ยท (Permalink)
If there are methods to check for empty strings I tend to use them, I think that's just good practice really, even though it could be prettier.
devdot ยท 3 points ยท Posted at 13:49:49 on June 10, 2016 ยท (Permalink)
Yep, code is about readability. I don't get people who want to optimize their PHP. Best optimization of PHP is not using PHP.
tastychicken ยท 1 points ยท Posted at 13:57:35 on June 10, 2016 ยท (Permalink)
Optimization is good though, but I seriously doubt using isset, empty etc will have a big impact on your applications performance.
I haven't done PHP in a long while (mostly c# for the moment) but there's a lot of people that want to do weird shit in c# as well because it's "optimized".
There are lots of ways to legitly optimize your code and they chose to fuck up their if/else blocks and other shit.
komtiedanhe ยท -1 points ยท Posted at 18:04:47 on June 10, 2016 ยท (Permalink)
How is 'if ($value != "")' easier to read than 'if ($value)'? What level of coder are you exactly "optimising readability" for that doesn't know the two are the same? Alternatively, what application are you writing where the distinction between null and an empty string really matters?
teddy_beer_maniac ยท 1 points ยท Posted at 19:44:21 on June 10, 2016 ยท (Permalink)
Except when they are not the same:
komtiedanhe ยท 1 points ยท Posted at 20:16:53 on June 10, 2016 ยท (Permalink)
I know they can be different. I meant the difference is functional, not related to legibility.
[deleted] ยท 5 points ยท Posted at 12:20:23 on June 10, 2016 ยท (Permalink)
What if $value is 0?
isavegas ยท 1 points ยท Posted at 16:53:55 on June 10, 2016 ยท (Permalink)
I actively keep an eye open for redundancy when I'm programming. Developed the habit when I was learning Java. It's verbose enough without stuff like that everywhere.
Boiled_Potatoe ยท 1 points ยท Posted at 07:57:29 on June 15, 2016 ยท (Permalink)
...what's wrong with that? What would you do?
Salanmander ยท 1 points ยท Posted at 10:39:44 on June 15, 2016 ยท (Permalink)
Just
if(x > 5).If x is more than 5, then x MUST be more than 3, so you don't need to check it.
Boiled_Potatoe ยท 1 points ยท Posted at 10:42:04 on June 15, 2016 ยท (Permalink)
Oh. I didn't read it well enough. Got it!
mrtwidget ยท 32 points ยท Posted at 18:57:16 on June 9, 2016 ยท (Permalink)
It would seem that the administrative position responsible for this ad does not require quite as many.
[deleted] ยท 12 points ยท Posted at 20:57:23 on June 9, 2016 ยท (Permalink)*
[deleted]
teefour ยท 3 points ยท Posted at 13:42:28 on June 10, 2016 ยท (Permalink)
They're arbitrary numbers anyway. At the end of the day, they'll likely hire the most experienced person they can get for the salary budget they set.
Astrokiwi ยท 19 points ยท Posted at 11:25:33 on June 10, 2016 ยท (Permalink)*
I notice there's a gap between the top few points and the bottom ones - I wonder if it was supposed to be "required skills" as the top, and "desired skills" at the bottom, but they left out the line of text that explained that.
Edit: The top skills look like really baseline stuff - you basically just need experience in any OO language, plus all the web fundamentals of HTML etc - while the bottom stuff is more specific. I'm not even a web developer, and I satisfy most of the top criteria. But I don't really even know what REST and SOAP are...
devdot ยท 6 points ยท Posted at 13:17:27 on June 10, 2016 ยท (Permalink)
The guy who made this page probably had only 3+ years of experience.
Guerilla_Imp ยท 1 points ยท Posted at 15:12:26 on June 10, 2016 ยท (Permalink)
If you look at the rest of the openings I am pretty sure that is the case.
ShowMeYourTiddles ยท 12 points ยท Posted at 00:17:59 on June 10, 2016 ยท (Permalink)
var yearsOfExperience = buzz * 2;
LondonNoodles ยท 7 points ยท Posted at 13:21:27 on June 10, 2016 ยท (Permalink)
I never understand the point of putting down things like "must be able to work in a fast paced environment" or "passion for building a rich and innovative user experience".
Are they really some applicants who read this and think
"Oh no, I was dreaming to work for them, but I am only able to work in a lazy-ass environment, and I only enjoy building poor and old school user experience. Oh well, I'll keep job hunting until I find the right one!"
๐๏ธ PDX_Bro ยท 11 points ยท Posted at 18:07:37 on June 9, 2016 ยท (Permalink)
This was found in this job listing on StackOverflow. No prefacing separations between these two requirements at all haha.
Looks like their hiring department may have a copy + paste issue...
tsoliman ยท 15 points ยท Posted at 23:35:49 on June 9, 2016 ยท (Permalink)
I think maybe it was 2 separate lists like minimum vs recommended and that got lost.
rcenzo ยท 5 points ยท Posted at 10:31:30 on June 10, 2016 ยท (Permalink)
It's just 5+ years. He's only reassigning the variable, right?
vanamerongen ยท 6 points ยท Posted at 11:58:20 on June 10, 2016 ยท (Permalink)
I mean I guess 5+ years is still technically 3+ years as well.
repooper ยท 4 points ยท Posted at 04:00:05 on June 10, 2016 ยท (Permalink)
React, Angular, and JQuery are AJAX libraries? Or do I not know how to read?
jsdsparky ยท 3 points ยท Posted at 04:32:14 on June 10, 2016 ยท (Permalink)
Why not both?
JamesonG42 ยท 6 points ยท Posted at 10:27:49 on June 10, 2016 ยท (Permalink)
Why not Zoidberg?
A-Type ยท 2 points ยท Posted at 12:51:41 on June 10, 2016 ยท (Permalink)
I think you could parse it as
Experience developing AJAX interfaces with { AJAX libraries (<no examples given>) and [JavaScript] frameworks (<JavaScript framework examples given>) }Either way I'm not sure what they mean by that, even as a fullstack dev. You want to know if I can... make AJAX requests from a JavaScript client? Define a client-server API? Roll my own AJAX tools?
SilasX ยท 3 points ยท Posted at 21:25:03 on June 9, 2016 ยท (Permalink)
That's a test of whether you can notice and simplify logical expressions, duh.
Darkitz ยท 4 points ยท Posted at 10:21:33 on June 10, 2016 ยท (Permalink)
i understand that companies want programming experience. Because when studying computerscience you learn jackshit about programming
8BitAce ยท 5 points ยท Posted at 11:03:38 on June 10, 2016 ยท (Permalink)
Well ya, CS isn't really about programming. That's just a component.
[deleted] ยท 5 points ยท Posted at 10:37:40 on June 10, 2016 ยท (Permalink)
Depends on the University, but overall I'd tend to agree. In four months at a software company I learned much more about programming than in 3 years studying CS.
Magical_Gravy ยท 1 points ยท Posted at 12:46:15 on June 10, 2016 ยท (Permalink)
What do you learn?
Darkitz ยท 2 points ยท Posted at 12:52:48 on June 10, 2016 ยท (Permalink)
projectcontrolling, designbasics. hardwarestuff, documentation, uml. Ofcourse theres some java and c. pure c is only really 1/36 of a bachelors degree and java is about 5/36. webdevelopment: another 1/36.
If you like programming you better not study computerscience.
it makes me wanna kill myself :(
parenthesis-bot ยท 7 points ยท Posted at 12:53:36 on June 10, 2016 ยท (Permalink)
:)
This is an autogenerated response. source | /u/HugoNikanor
trentv4 ยท 1 points ยท Posted at 14:17:50 on June 10, 2016 ยท (Permalink)
Aww, good bot
Magical_Gravy ยท 1 points ยท Posted at 13:02:08 on June 10, 2016 ยท (Permalink)
Don't you do a programming project? Or like a group project?
Darkitz ยท 1 points ยท Posted at 13:12:50 on June 10, 2016 ยท (Permalink)
yea the bachelor project is a semester after all the courses. But it doesnt really need to have any programming effort in it.
Magical_Gravy ยท 1 points ยท Posted at 13:13:47 on June 10, 2016 ยท (Permalink)
Well...piss.
tastychicken ยท 1 points ยท Posted at 13:43:28 on June 10, 2016 ยท (Permalink)
Then again, all those things are stuff that really helps you when actually develop stuff.
I started with spaghetti coding as a hobby and finally got "experienced" enough to get an actual job as a developer.
I still sometimes stumble upon things CS students learn and I'm like "whoa, that's pretty useful, why haven't I done that yet?".
madcapmonster ยท 2 points ยท Posted at 12:21:46 on June 10, 2016 ยท (Permalink)
Well they have plus signs, you obviously add them together.
Thoguth ยท 1 points ยท Posted at 11:15:08 on June 10, 2016 ยท (Permalink)
They're hiring for two different positions, obviously.
trolliyer ยท 1 points ยท Posted at 13:36:22 on June 10, 2016 ยท (Permalink)
What was the position title OP?
artbart84 ยท 1 points ยท Posted at 17:50:21 on June 10, 2016 ยท (Permalink)
If it's cascading then it should only be 5 :p