T
2

My old college buddy told me my code was too messy and I got defensive but he was right

I was showing him this script I wrote for scraping our local weather data and he just said 'dude this is like a spaghetti monster threw up on my screen'. I was annoyed at first because I spent like 3 hours on it Sunday night. But then I looked at it again and realized I had like 12 nested if statements and no comments anywhere. He showed me how to break it into functions in like 10 minutes and now I can actually read what I wrote from last week. Has anyone else had a friend call them out on bad habits and it actually helped?
3 comments

Log in to join the discussion

Log In
3 Comments
kim191
kim1912mo ago
Disagree a little here. I've had friends criticize my code too and sometimes it just comes down to style differences, not actual messiness. lol One guy told me my variable names were too long and descriptive, but honestly I'd rather read "temperature_fahrenheit" than "tmpF" when I'm debugging at 2am. Not saying your buddy was wrong about the 12 nested ifs because that's rough, but not every critique is gold. Some people just like things their own way and that's okay too.
7
kimreed
kimreed1mo ago
Right, but where do you draw the line between style and straight up bad practice? Like, long variable names are one thing, but I've seen people argue that using 'i' as a loop counter is "confusing" and insist on 'loopIndexForCustomerArrayProcessing' or whatever. That's not better, that's just making your code a chore to read. So is it really about what's easier to debug, or are we all just picking our own pet peeves and calling them best practices?
2
the_lucas
the_lucas2mo ago
Man, bad advice is everywhere but 12 nested ifs is not a style difference. That's a cry for help. Your buddy did you a solid.
1