Whats better new module new function or all functions in one module?

Lightwave

Ad astra
Local time
Today, 00:35
Joined
Sep 27, 2004
Messages
1,537
I know to a certain extent its academic but what do you guys normally do?

New module for each new function

or

All functions in one module..

Kinda curious I don't have a great deal of functions but I am tending towards new module for each new function.
 
I wouldn't put each Function, or Subroutine into a separate module.

However, I would use separate modules to group together all functions which are related.

For example, I would probably use:

modSecurity (Module of security related functions and sub-routines)
modCommon (Module of miscellaneous functions which are reused in many projects)
modMain (Module of functions related to the application which don't appear in the other modules)

If you reuse some modules of code including a version number of some kind can be very useful.
 
Two unrelated ways of looking at it.

1. When you store a file on disk do you always create a new directory for it?

2. If your Functions are in separate Modules and you want one Function to call another then the called Function would need to be Public. Very often you will have one Public Function in a Module and several Private Functions which service that Function. One way to find out if Functions are related is to see how many of the Functions can be made Private.

Chris.
 
a long while ago, when i used to use pascal, and memory management was important you could manage which routines you put in each module, and control which modules were swapped out when others had to be swapped in.

so, i am not sure whether vba does a similar thing - but if it does, it makes sense to try and keep commonly used functions in a module together, so they are unlikely to get swapped out, and otherwise try and put ones that get used together in the same module.

nowadays we have a lot of memory, so it probably only becomes an issue if we are running lots of apps. you would get some idea from task manager / physical memory usage, i guess.
 
I guess I pretty much did that but I really have never looked at the structure of modules in other peoples databases.
 

Users who are viewing this thread

Back
Top Bottom