When to split code into files/modules?
file, module, project, python
Solution
I usually do it under these circumstances:
- You could run parts of the application on thir own and running them would be useful (so they could be reused)
- A part of the application is abstract and the rest is concrete (The abstract parts could be reused)
- I want to divide it into 'plugins'
- A single script would get insanely large (then I divide e.g. by class or put the unittests into a separate file).
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.
Problem
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).