|
|
|
|
|
by tlrobinson
3800 days ago
|
|
That's still true but on the module level. If your module is so large that it's hard to keep track of the imports/requires then you should probably split the module up. I really don't think require-ing within individual functions is a common or good practice. Can you point me to an open source project that does that? |
|
Splitting up a program, or module, into (more) modules does not make it simpler, rather contrary, it makes it more complex! Unless it's a fully decoupled abstraction reusable in other projects.
An example of require-ing within individual functions: A function to send notifications to e-mail or SMS ... It makes more sense to require the SMTP or SMS module in those functions, then somewhere else.