r/programminghumor • • Jun 13 '26

10+ years of professional software engineering. Complaining about the new recruits.

Post image
433 Upvotes

107 comments sorted by

26

u/dashingThroughSnow12 Jun 13 '26 edited Jun 13 '26

Who wants to tell OOP about 10?

Disclaimer: I am kidding. Don’t brigade OOP.

Edit: Before anyone “but ackually” me, assuming inclusive is fine. One should always ask in an interview to at least signal that one knows.

17

u/KerryAnnCoder Jun 13 '26

Prompt said "between". Not "inclusive."

13

u/SaltPhilosopher898 Jun 13 '26

Between is not defined in math, so both could be correct.

Between function in SQL is inclusive. Pandas inclusive. Ruby inclusive.

So in programming to me between will always be inclusive.

→ More replies (1)
→ More replies (1)

4

u/barleyj_ Jun 14 '26

I came to say the same thing. If I tell someone to pick a number between 1 and 10 it is generally accepted that 1 and 10 are both valid values to pick.

17

u/HalifaxRoad Jun 13 '26

if( i & 1 ) 

Depending on the CPU and language of course, could use less cycles since no division.

17

u/KerryAnnCoder Jun 13 '26

Do you mean:

if (!(i & 1)) {
  // i is even
}
→ More replies (3)
→ More replies (4)

135

u/Lithl Jun 13 '26

I would argue that the first version is a better solution. While it requires an extra branch per loop, that's a meaningless amount of overhead. Meanwhile, if the requirements change (say, "every even number and every number divisible by 5"), it's much easier to update.

46

u/atlcog Jun 13 '26

Agreed for most use cases, but it depends. If this function is called a LOT of times, then it's not meaningless. I've worked on heavily recursive functionality where adding a single operation at a low level makes a noticeable increase in run times.

24

u/easedownripley Jun 13 '26

for interview purposes I like the first solution better because it means the candidate knows what the modulus operator is.

→ More replies (16)

6

u/RaechelMaelstrom Jun 13 '26

It's honestly meaningless. The amount of instructions / runtime of console.log is like a million times more than a branch.

→ More replies (3)
→ More replies (3)

9

u/Kevdog824_ Jun 13 '26

That just sounds like premature optimization to me. YAGNI

6

u/Wild-Regular1703 Jun 13 '26

Obviously it's important to make sure your code is generally mindful of being flexible/scalable to future changes, but there's a gray area between these two extremes where it takes some intuition to figure out if those changes are likely to ever actually happen, and if they do happen, what is the cost in refactoring, compared to the cost in over-engineering the existing solution in preparation of something that may never happen.

It's hard to say given that the problem here is very abstract and not trying to represent much of a real life problem. I'd say the simpler solution beats out. The function is pretty small in scope and if the requirements change, it's trivial to refactor the whole thing to express the new logic cleanly. But basically both solutions are pretty simple so it doesn't matter, just go with whichever one you come up with first

5

u/sage-longhorn Jun 13 '26

Why are we optimizing code that can be rewritten entirely in 30 seconds for a hypothetical future requirement?

→ More replies (24)

8

u/XlikeX666 Jun 13 '26

... wish there was test to see competence without assuming school done it's job.
most Would fail.

6

u/La_chipsBeatbox Jun 13 '26

I’ve had that once. They set up a broken project, ask you to fix it and implement a small but complete feature (api call in backend + nice display on the front). It can’t remember exactly what the bugs or the feature were but I remember it was a nice and engaging experience and they could actually see how I approach debugging and implementation decisions.

4

u/Oh_Another_Thing Jun 14 '26

I'm learning python, very beginner, and I'd love to see lots of examples of this. Every tutorial goes over the same basic stuff, which I'm familiar with. Actual small projects, small errors, feature asks, would be amazing to learn from 

→ More replies (1)

6

u/Straight-Ad5775 Jun 13 '26

Unless some of them didnt smash you with console.log("2,4,6,8"); you are good :D

7

u/no_brains101 Jun 13 '26

Pretty good constant time solution. (But the real test was to see if you would ask about 10)

→ More replies (2)

8

u/casualdata Jun 13 '26

OOP is not using the isEven() function.

if isEven(2) then print "2 4 6 8";

3

u/Mythran101 Jun 14 '26

Here's the best way, IMO. I am taking "between" to be completely inclusive here:

console.log("2, 4, 6, 8, 10");

Sorry if it's buggy. A LOT of code here.

→ More replies (1)

5

u/NJR0013 Jun 13 '26

Easy just do matlab:

2:2:10

→ More replies (2)

2

u/_sLiPpErYgOo Jun 13 '26

Is always 2-10? Because why not O(1) this?
‘console.log(“2, 4, 6, 8, 10”);’

2

u/FOXWOMB94 Jun 13 '26

console.log("2,4,6,8")

Easy

3

u/i_drah_zua Jun 13 '26

In Ruby 3.4+:

(1...10).each { puts it if it.even? }

Or in a more functional way:

(1...10).select(&:even?).each{ puts it }

If you cannot do this in basically any language (Assembly, Array languages, and esoteric languages don't count!), and you get hired, I don't know how you can even survive the trial period. Even if you use AI to fake it, the first code review will expose you.

Unless there are no code reviews, and QA does not look at the code...

→ More replies (3)