To date I had been developing only small Python scripts. They were not longer than 500 lines per each. Now I'm going to write something bigger - I think it will have about 1000 lines. Is it good idea to handle it in one file or is it good time to organize code in subdirectories? I found some advices on how to modularize code, but I can't find any information about when to do that (or rather when it isn't waste of time).
To prevent the requirement of downloading ginormous files, scripts can be split into multiple smaller files. Then features required at page load can be downloaded immediately with additional scripts being lazy loaded after the page or application is interactive, thus improving performance.
Most programs are more than a few lines long. This means that they have to split into multiple small pieces for them to be manageable. Python programs can be split into modules.
I usually do it under these circumstances:
In general I try to go for reusability. If I cannot divide it into reusable parts I don't divide except it would get too large.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With