The source code for modules is typically organized as multiple source files. Although there is no hard and fast rule about how source files are organized, the following are useful guidelines:
- Coupling: Highly coupled functions should be placed in the same file. Doing so allows less context switching when editing source files. For example, when you change the signature of a function, all callers of that function may need to be updated. Ideally, you would want to minimize the blast radius and not have to change many files.
- File size: Having more than a few hundred lines of code in a single file could be a warning sign. If the code inside the file is all tightly coupled, then it may be better to redesign the system ...