r/learnpython • • 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

57 comments sorted by

View all comments

8

u/life_never_stops_97 Jul 17 '20

I'd also suggest to look up OOP. It makes your programs scalable and really neat.

I was doing a lot of coding in python using functions and that's fine but recently I got an internship and when I see their code I was literally amazed at how they used their python code and made it scalable.
They had a scraping website that scraps stuff and I was amazed to see how everything has a module of it's own. They had their own request module, query manager to pass queries, base scraper that has methods like get_request, post_request, get_form_data , exceptions module and all were connected to each other to do one big thing(Scrape). It felt so right

4

u/dhruvmk Jul 17 '20

Imo you should only use OOP if you can find a way to link two classes using inheritance, that way a lot of code can be saved. If you need to quickly code an algorithm on the fly I'd recommend just using functions. But you are right, OOP brings scalability.

5

u/life_never_stops_97 Jul 17 '20

I agree with you on the part that functions are good if you're solving a leet code problem or just prototyping but most of the time a real world project could be refactored into OOP. It might not be easy to think in terms of how one module would connect to the other one and its definitely not obvious to see that in the first try but it's possible.

3

u/dhruvmk Jul 17 '20

That's very true, most complex systems implement some sort of object oriented paradigm