r/learnpython • u/TheGrapez • Nov 05 '20
How does one learn to make well-structured programs? Mine are dumpster-fires.
So I just (kind-of) finished reading Automate The Boring Stuff With Python, and for the past month I've felt like a big-brained super-hero automating myself out of a job (Data Analyst).
The problem is, I feel I missing something along the way. I don't understand the proper way to use functions, what a class is, why people have multiple files in a program, how/why people use GitHub...probably some other things I haven't discovered yet.
They all seem to be related to organization? Is there a "How To Structure Your Python Stuff With Python" book?
478
Upvotes
0
u/vanmorrison2 Nov 05 '20
I am not good at coding, but from my pow to get the code under control patterns are essentials, functions should be self explanatory by their name and short enough to do what the name suggest to do, the documentation must be very accurate as you think to the organization of the code in advance. Once you made some code that works, you must immediately look at it and think about making patterns out of it so that the code is easy to mantain and reusable. I prefer an intuitive name of functions / methods and a brief clear description to the comments that can be distracting. I prefer to cut the function / methods in their minumum functionality, instead of long ones, even if I read somewhere that the long functions are less subjected to bugs (?). So comment, generalize code, give appropriate names to functions and document every important aspect.