Program and Class Organization

I’m pretty new to programing. Python is my first and only programing language, and I am self-taught through YouTube, ChatGPT and various websites including discussions on this forum. I’ve written several programs and now I’m running into a problem of organization. I’ve created classes however I KNOW that a bunch of the methods in my classes are way to complex and super specific. I just don’t know the best practices for program organization which causes issues each time I need to re-run a report I find myself trying to either re-factor (I’m still learning so much and if I wrote something more than a month ago, I have more than likely learned a better method to do what I previously did.) or looking for an error thrown which then sends me into the trouble shooting phase and it really all just boils down to me being new to programming in general and not understanding how to organize each programs files.

I’m trying to learn how to organize each program vs overall programing (meaning classes and methods that can be used in more than one program). Am I overthinking this or are there any suggestions that might help me organize better?

Hello,

What it appears you’re attempting to understand is how to best organize libraries; libraries being modules that contain similar objects. The way to go about is to start grouping classes / methods / functions that have similar functionality into their own modules. Then, if you have a need for such objects for a particular application, import the module (i.e., library), where needed. Just make sure that the library is in the search path of the application.

For example, you can create a library that specializes in math related functions (related to a specific field). You can create another library that specializes in different types of plots (for example, if you pass in two lists of values for x and y, a specific type of plot will be generated), etc.

The more you program and practice, it will be as if though an “invisible hand” is at work (reference Adam Smith). :wink: