Modules

D

DCPan

OK, I have what is hopefully a very basic question.

What is the best practice for deciding which sub procedures go into which
modules?

For example, if a particular procedure B is only called by procedure A, is
it better for them to reside in the same module?

At what point is a module "too big"?

Thanks!
 
R

Robert Morley

I might be a little out of date, but if they haven't changed it, then Access
loads modules "on-demand". So if Procedure B is only called by Procedure A,
then yes, it's best if they're both in the same module so that they both get
loaded simultaneously.

Similarly, procedures that are more or less guaranteed to be called by your
code at some point could also be grouped together. (To a point...logical
design usually takes at least some precedence over the minute speed gains
this would give you.)

The corollary to that is that procedures that won't necessarily be called by
your code should be separated. (Again, to a point...it's probably not
particularly effective to separate every last "optional" procedure into its
own module.)

As for "too big", there's not much in the way of firm guidelines. At one
point, there was a hard limit of 64k of text in a module, but I'm not sure
if that still applies. Basically, it's whenever you find a module too unwieldy.


Rob
 
A

Albert D. Kallal

For the most part, you want to group similar code together.
For example, if a particular procedure B is only called by procedure A, is
it better for them to reside in the same module?

Yes, and the procedure B should be declare as private so that other modules
and code can't use, or call that code by accident.
At what point is a module "too big"?

Quite large. For the most part I NEVER had to break up a module because it
is large. On the other hand, I do group code by use and function. Here is a
screen shot (access 2003) of some modules in a typical application. Note the
names and logical grouping of the code.


http://www.members.shaw.ca/AlbertKallal/test/index2.htm
 
R

Robert Morley

Tsk, tsk, your "apiShell" and "ApiShellWait" aren't following the same case
conventions. <g>


Rob
 
A

Albert D. Kallal

Robert Morley said:
Tsk, tsk, your "apiShell" and "ApiShellWait" aren't following the same
case conventions. <g>

Even worse is in that example, the two code modules actually overlap in
functionally. However, the problem was I could not risk deleting or
modifying the old module for fear of breaking some code in the overall
application (the application has 30,000+ lines of code.

A good many of the modules were imported from other applications, and over
time naming conventions have changed.
 
R

Robert Morley

Yeah, I'm not exactly in the best position to comment, myself, actually. I
have a couple of views in my SQL database that start with "tbl". It
probably doesn't take a lot of imagination to figure out why. :)


Rob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top