View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Jim Thomlinson[_3_] Jim Thomlinson[_3_] is offline
external usenet poster
 
Posts: 983
Default Organizing functions

My assumption here is that these are utility type functions. Let head through
this one question at a time.

How should they be organized. Grouping items togethter by functionality is a
great idea. It doens't change the processing time one little bit, but from an
understandability stand point it makes a lot of sense. If you have a module
with a few different text manipulation functions, then group them together.
If there is a problem with a text function you know immediately right where
to look. Grouping into a number of smaller categories also makes a lot of
sense from the standpoint of code re-use. I have a number of different
modules of utitlity type functions that I import into new projects. One for
Error handling, one for protecting and unprotecting, one for ADO DB
recordsets... Creating a new project becomes "plug and play".

In terms of commenting. Always, always, always comment. There should be some
sort of a preable at the beginning of your function indicating what it is,
what it does and how it is used. You should not have to read the code to
understand the function. When you write code you should comment throughout. I
will rarely go more than 5 lines without a comment. All of my variables are
commented. My code can be read by anyone and understood. If I come back to
something 6 months later to modify, it takes me no time at all to get up to
speed and make the changes.

Should it be in an add-in. If it is something that you will be using all of
the time then probably. Addin code is a little faster because it is
pre-compiled.

Just my two cents...

"Knut Dahl" wrote:

Good afternoon everyone,
I've got more of a style question than technical one this time around. I'm
currently assembling all my custom functions and subs into one project. I
have been collecting some over the last couple of projects I've done, so I
thought it might be a good idea to have the ones I use very often together.
I am currently on 50-60 of them. The thing is that I've read so many
different opinions about how to store them.
Should I group them in different modules, or should I just create one big
module and comment every sub I have? Is there a processing-time difference
of having let's say 10 different modules or just having one big one?
Second question: should I save it as an add-in or would you recommend me
saving it as a normal spreadsheet?
I'd appreciate any comment on this matter.
Thanks guys ;o)

kj