26
That whole clean code obsession I dismissed for 5 years finally clicked
I always thought people going on about clean code were just being fussy. Then I had to fix a function my coworker wrote last March that was 400 lines long with no comments. Spent 4 hours just figuring out what it did, and I realized writing messy code costs way more time than writing it clean the first time. Has anyone else had a moment where they finally understood a coding principle they ignored for years?
3 comments
Log in to join the discussion
Log In3 Comments
pat_murray533d ago
Is it just me or does that 400 line function sound like a horror story waiting to happen? I've been there too, staring at a wall of code for hours feeling like a detective with no clues. But I gotta say, my own "clean code" attempts have backfired so bad I once spent a whole afternoon trying to find a bug across 15 tiny functions, only to realize I broke it with a typo in a helper file. I think we all have that moment where we swing too far one way or the other, right? These days I just try to keep it simple enough that Future Me won't want to punch Past Me.
5
Push back hard on this one. That 400 line function your coworker wrote? It might have been a work of genius if you'd just taken the time to understand the business logic instead of getting hung up on line count. I've seen clean code turn into this mess of tiny functions that break everything when you change one line. Clean code purists often end up with 10 files to do what one messy function could handle in half the lines. Your mileage may vary but I've fixed way more bugs caused by over-engineered clean code than I ever did from one big ugly function.
4
wesleyflores3d ago
Right, because nothing says "genius" like scrolling through 400 lines to figure out what the heck a variable named "temp" does on line 387. Clean code is a nightmare sometimes, sure, but let's not pretend giant functions are some sacred art form either.
2