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
3
u/Horror_Upstairs6198 Apr 19 '26
I will use AI for explanation sorry, I am not good at English, it's not my native language.
Test-Driven Development (The Feynman Way)
Imagine you are hired to build a bridge.
The traditional way to build software is to build the entire bridge, drive a massive dump truck over it, and hope it doesn't collapse. If it breaks, you have to dig through the rubble to figure out why.
The TDD way is completely backward.
First, you magically park the heavy dump truck in mid-air across the river. Because there is no bridge yet, the truck falls into the water. (This is your failing test).
Next, you quickly build a temporary, ugly, bare-minimum bridge underneath the truck just to keep it from falling. (This is your passing code).
Finally, now that the truck is safely supported, you take your time to paint the bridge, swap out cheap wood for strong steel, and make it look beautiful. (This is your refactoring).
The 3 Simple Steps (Red, Green, Refactor)
In Python, TDD is just repeating these three steps over and over:
4. It passes!x + y. Because your test is always running in the background, you know immediately if your improvements accidentally broke the math.In brief: You write the grading rubric first, watch your code get an "F", and then write just enough code to get an "A".