Per Harold Good:
Hi, I'm trying to learn how to be better organized with code. I can't
find anywhere why someone would want more than one module for general
code. Yet I see Module 1, Module 2, etc.
Is it because some code gets really long?
Is it to better organize code, even if not long?
Both.
Also, there's portability.
For instance, one might have a module that is dedicated to
parsing and displaying errors. If that module contains all the
needed code - and only the needed code - the functionality can be
easily copied to other applications.
Excel is a concrete example for me. I've a module I call
"basExcel" and it has routines to open a new spreadsheet, open an
existing spreadsheet, make sure a tab name is legal, and so-on
and so-forth. Whenever I write a new app that has to do stuff
with Excel spreadsheets, I just copy that module into it.
How many modules do some of you pros end up with?
Depends on the app.
Right now I'm looking at a bond trading application that has 37
modules.
6 of them are unique to the application, but always present in
every app:
basAutoExec
basCalc
basGlobals
basReport
basTree
basValidate
21 of them are the same or very similar code in every
application:
basAppKill
basAutoExec
basBizDay
basBugAlert
basColor
basCommonFileDialog
basConnect
basEmail
basErrorCheck
basErrorCodes
basExcel
basFollowHyperLink
basGuid
basLogFile
basParseToArray
basScreenModeSet
basStickTo
basSubDataSheets
basTextWidth
basUtility
basWorkTables
Any tips on how to organize code into various modules, renaming them to
be more meaningful, and organized.
Portability is my primary concern.
I prefix module names with "bas", just because I like to be able
to tell what kind of object something is by looking at the name.
"tbl..", "qry...", "frm...", "rpt..." and so-on and so-forth.