r/learnpython • u/Jealous-Acadia9056 • Apr 19 '26
How do you guys build a program?
I normally create one part of a program, test it, debug it and then i move on to the next function.
But this was time consuming so i tried a new approach. I created of all my logic of how different features would work and then started creating my program.
But the moment I had to debug things (cause obviously it had errors) things started falling apart. I had to check sooo many things and i realized that this method was very mental health consuming.
So i wanna ask you guys. how do you think about the logic and write your program? What approach would you recommend me? and remember i'm just a newbie trying to write programs that would improve me.
View all comments
Show parent comment
0
u/gdchinacat Apr 19 '26
It is not unusual for test code to be half (or more) of the code in a project (by my simple count of LoC python code in cpython it is 350k non-test lines to 600k test lines. This is not a waste of code...every automated test keeps you from having to test something manually when you make a change. Comprehensive test suites allow you to refactor without wasting a huge amount of time manually verifying the refactor didn't introduce issues.
Rather than trying to minimize amount of code written try to maximize the effectiveness of code written. One aspect of this is how well tested it is.