M
Martin Gregorie
I'm currently writing a set of closely related programs which all run
against a fairly simple RDBMS schema. There's little or no overlap
between the operations they apply to the DB (one batch loads data,
another interactively retrieves it while the third weeds out
unwanted/old data).
Currently only the loader is complete and running. I've put all its SQL
operations into a single class, using a small set of public methods that
map well to the program's DB manipulation requirements. The DB functions
for the remaining programs are fairly disjoint so their SQL operations
could be encapsulated in separate classes apart from a few methods
(currently implemented as private) which are likely to be common to all
programs.
I can either split out the few common methods into a separate class
which is extended to provide separate database access classes for each
of the programs or I can build a single, large class that exposes all
the database access methods used by these programs. Polymorphism is
irrelevant: each program only needs a single instance of its database
access class.
- Which is the best of these approaches?
- Is there some better third way I should be using?
Currently I'm leaning toward the single database access class because
this is similar to the way large classes such as StringBuffer are
structured in the JDK class library.
All comments and suggestions are welcome.
against a fairly simple RDBMS schema. There's little or no overlap
between the operations they apply to the DB (one batch loads data,
another interactively retrieves it while the third weeds out
unwanted/old data).
Currently only the loader is complete and running. I've put all its SQL
operations into a single class, using a small set of public methods that
map well to the program's DB manipulation requirements. The DB functions
for the remaining programs are fairly disjoint so their SQL operations
could be encapsulated in separate classes apart from a few methods
(currently implemented as private) which are likely to be common to all
programs.
I can either split out the few common methods into a separate class
which is extended to provide separate database access classes for each
of the programs or I can build a single, large class that exposes all
the database access methods used by these programs. Polymorphism is
irrelevant: each program only needs a single instance of its database
access class.
- Which is the best of these approaches?
- Is there some better third way I should be using?
Currently I'm leaning toward the single database access class because
this is similar to the way large classes such as StringBuffer are
structured in the JDK class library.
All comments and suggestions are welcome.