My buddy Dave looked at 200 lines of my spaghetti code and said one thing that finally made me get functions
Last Tuesday I was at a coffee shop in Boise showing Dave my first real project, a text based dice game that had grown to 200 lines of copy pasted if statements, and he just pointed at three identical blocks and asked me which one I would fix if the bug was in all of them. It hit me right there that I had been writing the same logic over and over because functions felt like extra work, and after I pulled those blocks into one function the whole file dropped to 80 lines and the bug fix took 30 seconds. How do you all decide when a chunk of code is worth turning into its own function?
Ngl "which one would you fix if the bug was in all of them" is such a simple way to put it and I still would've sat there staring at my screen for 20 minutes. My rule now is if I copy paste something a third time I turn it into a function, though usually it's more like the fifth time and a lot of grumbling. Tbh my first dice game was one giant function called main and I was proud of it.