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

98 comments sorted by

View all comments

1

u/PolygonAndPixel2 Nov 06 '20 edited Nov 06 '20

You may take a look how people organize their stuff on GitHub and take a look at programs, that need to be compiled.

Most of all look for books about design patterns. That's pretty simple and easy to learn. My university recommends the following books:

Gamma, E., Helm G., Johnson R. & Vlissides J. (2002). Design Patterns - Elements of Reusable Object-Oriented Software. Addison-Wesley. ISBN: 0-201-63361-2Freeman E. & Freeman E. (2004). Head First - Design Patterns. O'Reilly. ISBN: 0-596-00712-4

The first one is by the Gang of Four and should be pretty popular.

Edit:
I disagree with any "art" speech. That just sounds like something that cannot be structured and analyzed and is somewhat magic. It isn't. Make yourself clear what your program needs, how classes might be reused and choose design patterns that seem to fit. It gets easier with experience of course.