B
33

Rant: Everyone keeps skipping the step where you actually test your code snippet before using it

I was helping a guy on a forum last night who spent 3 hours debugging a script, and it turned out the problem was he copied a code snippet from a 2014 Stack Overflow post without running it in a sandbox first. The snippet had a deprecated function call that just silently failed in modern Python 3.12. I used to think testing tiny blocks was a waste of time (like, come on, it's 5 lines), but after seeing his mess and realizing I've done the same thing at least 3 times this year, I'm fully on team 'test it in isolation first.' Has anyone else gotten burned by outdated code examples you assumed were fine?
2 comments

Log in to join the discussion

Log In
2 Comments
nora110
nora1108d ago
Man I heard some dev on a podcast say the average Stack Overflow snippet is like 6 years old now. That stuck with me. Really makes you wonder how many broken examples are floating around out there.
1
lunag30
lunag307d ago
6 years sounds about right honestly. I ran into an old jQuery snippet last week that used .live() and it took me a second to remember that was deprecated years ago. How do people even tell if something is still good without testing it themselves or digging through the comments?
10