19
That one critique from a senior dev 5 years ago that changed how I code
I used to cram everything into one function cause I thought it was faster. Then a senior dev at my job in Austin pulled me aside after a code review and said "your code works but nobody can read it." He told me to break it into smaller pieces even if it felt wasteful. At first it made my files longer but after about 3 weeks I realized I was fixing bugs way quicker. Has anyone else had a piece of feedback that seemed annoying at first but actually helped a ton?
3 comments
Log in to join the discussion
Log In3 Comments
milesbarnes6d ago
Hah, yeah I had a guy tell me my code was "like reading a choose your own adventure book but someone ripped out half the pages." At the time I was mad but he was totally right. I used to write these 200 line functions and call it "efficient" cause I was too lazy to type more function names. Breaking stuff up felt stupid at first but now I swear by it. The funny thing is my code got faster after I split it up too, not slower. I think the compiler just optimizes the hell out of small focused blocks anyway.
8
val9746d ago
Yeah but did it actually make your code slower? Breaking things up def helped me find bugs faster too. Honestly saved me from a few all-nighters.
6
ivan4626d ago
Dude "saved me from a few all-nighters" is exactly it. I had this one scraper that was a beast. Broke it into like five smaller functions and suddenly I could actually see where the memory leak was. Wasn't even slower. Ran faster after I split it up. Refactoring is magic sometimes.
1