F
22

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?
4 comments

Log in to join the discussion

Log In
4 Comments
fionat55
fionat551mo ago
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.
7
fionat55
fionat551mo ago
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.
7
casey268
casey2681mo ago
Sounds like he's about to learn the hard way.
6
kevin_williams
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.
3