r/programming • u/svpino • May 08 '15
Five programming problems every Software Engineer should be able to solve in less than 1 hour
https://blog.svpino.com/2015/05/07/five-programming-problems-every-software-engineer-should-be-able-to-solve-in-less-than-1-hour
2.5k
Upvotes
3
u/Otis_Inf May 08 '15
Oh you're so right. This week I had to implement a certain feature and I could do it in two ways: either the dumb way by traversing a tree many times, or the smart way by leveraging observer links so notifications were delivered where they should immediately. Long story short: the 'smart' way was so complex that it took the better part of a day and I couldn't get it bug free.. the edge cases were too hard, yet I pushed for this because my feeling of the dumb way was that it would be way too slow, indeed "will this design be performant enough?" was answered firmly with a 'no'.
Finally I gave up on the 'smart' way as I was deeply frustrated that day and implemented the dumb way in half an hour. To my surprise it wasn't even noticeable that it did a lot of work over a tree, multiple times. All the work to avoid something that wasn't even real.
So I agree, and it's a problem to still fall for the 'it's not fast enough, we have to avoid it with a clever algorithm' fallacy I think but it's hard to root out, as for so long we all have learned that everything is slow, and you have to avoid as much actions in your code as possible to avoid slow code / bottlenecks.
Indeed, I/O, allocations (as memory is still slow), they're the things to avoid, cpu stuff... not so much.