r/learnpython • u/rkarl7777 • Jul 16 '20
Where to learn about Python program structure/design?
I'm self-taught in Python and am able to write programs that work, but I still don't feel like I know what I'm doing. Where can I learn about program structure/design?
I usually just start coding and one thing leads to another and pretty soon, I'm done. But I can't shake the feeling that a professional programmer would look at my code and laugh at how haphazard and inefficient it is. Any pointers or suggestions? Or are we just supposed to figure it out for ourselves?
375
Upvotes
28
u/six-speed Jul 17 '20
Here’s a few tips coming from someone who was recently in a similar place as you. It’s natural to want to dive in and start coding, but a major thing that separates pro develops from others is that they spend most of their time planning and thinking about how the code should work, and only write code after having spent most of their time planning. Learn about OOP - classes, inheritance, etc. Learn about testing your code, and learn about test driven development so that you write tests first and don’t have to reverse engineer tests for code that you already wrote. Finally, learn about code design, and try to think about and map out what your code should do before you start to write. Think about how things should be organized logically, and diagram classes and associated methods thinking about how data should flow into and out of them. Your code will be much cleaner if you do these things.