A legacy system I worked on had a logging table in the DB with an action_id column. The action ID's were mapped to constants in the code. The file that contained all the (130+) action constants and their ID's had a comment at the end:
// Increment this number if you change the max action ID!!!!
// 132
And I don't recall ever seeing it match the actual ID count, so I 100% believe it lol.
EDIT: found it!. The current highest ID appears to be 158.
... I see your time working with offshore development teams has been mercifully limited.
This really IS - EXACTLY - how Indian offshore teams tackle problems. No regard/effort put into anything except the immediate problem.
It makes me want to wrap my lips around the barrel of a gun.
EDIT: "It's a cultural issue." eyeroll.png. Yeah. Amazing how, if I'm an Indian working onshore, getting paid $150/hr, code like this would be a HUGE issue... but since I'm offshore at $20/hr the issues are brushed aside. Hmm.
I think the only "cultural issue" that needs addressing is in the boardroom, and maybe it can be addressed by a hard talk around shortsighted profit taking, and getting what you pay for.
Sounds real. This smells exactly like when they demand the bug reporter to list all exact steps and then fix only that exact scenario. You get infinite number of tickets to assign/fix/test/deploy/manage in your lovely job where you get paid for time, not for result.
Reminds me of the my classmates used to bend over backwards to avoid the % operator in intro CS classes because they couldn't be bothered to understand it.
You'd be surprised how many people forget first grade stuff. In there defense though, I can't really remember having much use for the concept of remainders before I learned to program.
Modulo is like the most useful operator out there. You can add speed to games every n points, make numbers loop on each other in recursions and other fun stuff.
Reminds me of myself, I forgot the % in an exam in school. We also had to write a piece of code to check if an int is even or not. My solution was to divide the int by two, then multiply it by two and check if it was the same number as the one given... worked like a charm :D
They are the same if the dividend and divisor are positive.
But if one or both are negative, then things can get a bit weird. The convention used can also change depending on the programming language. More here.
Wait for a "senior offshore developer" to look at this code then chide you for not writing unit tests, and especially for using a ternary operator "because it's inefficient."
Current code returns correct answer when number is uneven. Which is 50% of the time. Plus it returns correct answer for few even numbers. Therefore current code returns correct answer more often than just return 1;
If this person has a job, it gives me great hope about my future prospects. I mean how on earth do you spend more than 4 weeks learning CS and not know when to employ a for loop?
In early BASICs it was common to treat booleans as numbers
hours = 23;
hour = hour - (hours > 12 * 12)
rather than writing an if statement.
Somewhere I have a a single line of code that translates HH:MM:SS to h:mm:am with no 'if' statements, one nasty print statement using the above tricks.
776
u/amicloud Dec 19 '18
...no you fucking didn't, no way that's real.
177
u/[deleted] Dec 19 '18
Well they almost had all the even number covered. At least the ones in the range of numbers they know.
304
u/pixel_sharmana Dec 19 '18
When you are paid per line of code
131
u/[deleted] Dec 19 '18
You just added more checks right?
104
u/pqowie313 Dec 19 '18
Reminds me of the my classmates used to bend over backwards to avoid the % operator in intro CS classes because they couldn't be bothered to understand it.
219
u/triggerhappy899 Dec 19 '18 edited Dec 19 '18
Psssh amateurs, you could easily add the ability to check higher numbers
Just remember to set the number inside the for loop high enough to what you need. Ezpz
Edit: I am so humbled to be in the presence of all you intellectuals
25
u/UnchainedMundane Dec 19 '18
there's an easy fix:
if (a > 14) return isEven(a - 14);22
u/Serundeng Dec 19 '18
* QA proceeds to enter -2*
16
u/newPhoenixz Dec 19 '18
// :TODO: Add at least another 4 billion checks
80
u/bsep1 Dec 19 '18
public static int isEven(int a) {
if(a == 0) return 1;
if(a == 1) return 0;
return isEven(a+2);
}
18
u/Andernerd Dec 19 '18
You can't be serious... it hurts to think that this person was probably paid more than me.
9
u/Isvara Dec 19 '18
Did you add more checks?
7
u/pxOMR Dec 19 '18
You should return "Yes" instead of 1 and "No" instead of 0, it makes the code look cleaner.
/s
7
u/pootisEagle Dec 19 '18
// TODO: Add more checks.6
u/Montuckian Dec 19 '18
I can't even.
10
u/Frichjaskla Dec 19 '18
Use the power of recursion to cover more ground
5
u/[deleted] Dec 19 '18
I’m literally suffering from an aneurysm right now. Thanks I hate it
5
u/John_Fx Dec 19 '18
How many checks did you add?
9
u/InacmaR Dec 19 '18
r/thathappened
4
u/OverjoyedBanana Dec 19 '18
https://xkcd.com/221/
4
u/[deleted] Dec 20 '18
If this person has a job, it gives me great hope about my future prospects. I mean how on earth do you spend more than 4 weeks learning CS and not know when to employ a for loop?
3
u/lordpuza Dec 19 '18
Just curious , how will you guys solve this? Best that I could think of IsEven and if less than 14 ?
5
u/BluudLust Dec 19 '18
return !(number & 1)2
u/corner-case Dec 19 '18
Obviously the param ‘a’ is a 4-bit integer. I see nothing wrong with this.
2
u/Bioniclegenius Dec 19 '18
Wow, this is much better than the
that it was before!
2
u/bionicjoey Dec 19 '18
Relevant:
https://www.reddit.com/r/programminghorror/comments/77tg9z/z/dooj0ha
2
u/[deleted] Dec 19 '18
Obviously you just had to replace
ifs withelse ifs2
u/jstillwell Dec 19 '18
% 2
2
u/globalvarsonly Dec 20 '18
Just rename the function
isEvenNonNegativeIntUnderSixteen()Search and replace!4
u/[deleted] Dec 19 '18
Modulus operator brah, come on.
3
u/AttackOfTheThumbs Dec 19 '18
Where do you work. Was this code in production?
1
u/[deleted] Dec 19 '18
At least use a switch statement then
1
u/abdolence Dec 19 '18
The most frightening thing here is that last comment.
1
u/ivanjermakov Dec 19 '18
Everything is so bad with this code
1
u/thesocialpenguin Dec 19 '18
add more checks?!?!
1
u/sebnukem Dec 19 '18
// TODO: terminate myself1
u/sxule Dec 19 '18
This is my new test I'll give right before FizzBuzz. If they write more than one line, "Thanks for coming down. Now leave while you still can!"
1
u/[deleted] Dec 19 '18
Java doesn't have
%operators?1
u/wildlybland Dec 19 '18
That looks like dumb shit I used to write in college just to get an assignment over with when I first started taking programming courses
1
u/theblood Dec 20 '18
so... you added more checks ? :D
1
u/ouattararomuald Dec 22 '18
Best part is the TODO
1
u/papacheapo Dec 29 '18
This is what happens when managers offer their help to get the product out sooner.
1
u/[deleted] Dec 29 '18
Modulo anyone?
1
u/elschaap Jan 29 '19
At least NPM has a package for this
1
u/Dasky14 Feb 05 '19
FTFY /s
0
u/[deleted] Dec 19 '18
[deleted] — view deleted comment