TIL my friend's 'simple' Python script had over 200 lines of code because he didn't know about functions. | Coding For Beginners - Freelance Forum - The Community for Independent Professionals
TIL my friend's 'simple' Python script had over 200 lines of code because he didn't know about functions.
He showed me his project, a basic number guesser, and the whole thing was just one massive block of repeated if/else statements. I told him to break it into functions and he said he 'didn't see the point' yet. How do you convince a beginner that organizing code early saves huge headaches later?
Watch him try to fix a bug in that mess, @casey268. He'll get the point when he has to change the same thing in twenty places. The headache finds you eventually.
That "learn the hard way" thing is so true, and it's everywhere. It's like refusing to label moving boxes because you'll "remember" what's inside. You always end up ripping them all open later. Code without functions is just a giant, unlabeled box of logic. The mess is already there, you just don't have to deal with it until you need to find one specific thing.
Wait, didn't I read somewhere that even experienced devs still fall into that trap sometimes? I swear there was a whole blog post about it. @casey268 is right though, watching him dig through that mess later will be the real lesson.