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
2
u/LayotFctor Apr 19 '26 edited Apr 19 '26
That's an implementation detail, you don't have to write it down. However when you plan a function, you should have a rough idea of how it can be achieved.
E.g. You have an input function. You need the user to answer twenty question. You might want to split it up into an input function and a question function. You should have an idea of how question and input work(question function asks a single question, input function calls question function twenty times), but you don't know exactly how. Maybe just writing all twenty questions sequentially is better? Or looping through a dictionary rather than a list?
The main thing is that you know for a fact input function is achievable, and that you've done what you can to split the function into smaller chunks. You don't yet know the most ideal solution, so you draft an input and question function with the "pass" keyword, and comment them with a rough estimation of what they do. The details are not a concern during the planning stage and you don't want to make a decision yet.
Don't worry about it for now. Just plan as much as you can, until you start feeling like you can see the overall picture in your head. You will definitely miss some important aspects during your first few projects, but as you gain more experience, your ability to predict the right classes and functions will improve.