n
17

Hit 1000 lines of Python and it totally changed my mind about functions

I used to think writing functions was just extra work for beginners. Then last week I hit 1000 lines in my first real project and it was a MESS. I spent 2 hours just finding where a variable was defined. Now I break everything into tiny functions even if it's just 5 lines. Has anyone else had a specific line count where they just gave up and refactored everything?
2 comments

Log in to join the discussion

Log In
2 Comments
phoenixa64
phoenixa6427d ago
1000 lines is actually when most people hit that wall honestly. Functions aren't extra work, they're just a way to keep yourself from going insane later.
7
juliahall
juliahall27d ago
Pull up any project after six months and you'll see exactly what they mean. I've got a script I wrote last year, 800 lines in a single file, and now I can't even figure out what half of it does without tracing through each variable. Breaking it into functions would have saved me three hours of debugging last week. Plus when you need to reuse a chunk of logic later, it's already there waiting for you.
4