C
CB
I am an experienced but self-taught ASP programmer, and sometimes wonder
about major issues of principle in programming. For example:
I have a web application that iterates over a set of database records, and
displays each one on screen. The details of how each record is displayed can
vary a lot, so each record might have one to a half-dozen parameters
indicating how it displays, and the total list of parameters that any record
could have tops 40. Which of the following represents better programming
practice:
1) Create a parameters table in the database with a 1:many relationship to
the main records, and as each record is processed in the script, do a
database query to pull associated parameters, and store the resulting
recordset as an array in memory. At each decision point in the script, call
a function to check the parameter array and return values if present.
Advantages of this approach: orthodox database design; meaning of all the
parameters and their values is easily documented in the database.
Disadvantage: one to 50 extra database queries per screen, which will affect
performance and scalability.
2) Code the parameters into one or more fields in the main record (probably
one field for integers and one for text strings) separated by some marker.
For example, 2x0x5 for integers or text1&&&text2&&&text3 for text strings.
As each record is processed in the script, use the ASP split funciton to
create arrays of these parameters. At each decision point in the script,
check the appropriate position in the relevant array. Advantage of this
approach: no extra database query for each record. Disadvantage:
unorthodox, un-normalized database design; parameter sequence and meaning of
the values must be documented in the code, which can get messy; and setting
up the parameter strings for each record can be tedious and error-prone.
Overall, it seems to be a trade-off of hygeine vs. performance. Which
approach is better?
about major issues of principle in programming. For example:
I have a web application that iterates over a set of database records, and
displays each one on screen. The details of how each record is displayed can
vary a lot, so each record might have one to a half-dozen parameters
indicating how it displays, and the total list of parameters that any record
could have tops 40. Which of the following represents better programming
practice:
1) Create a parameters table in the database with a 1:many relationship to
the main records, and as each record is processed in the script, do a
database query to pull associated parameters, and store the resulting
recordset as an array in memory. At each decision point in the script, call
a function to check the parameter array and return values if present.
Advantages of this approach: orthodox database design; meaning of all the
parameters and their values is easily documented in the database.
Disadvantage: one to 50 extra database queries per screen, which will affect
performance and scalability.
2) Code the parameters into one or more fields in the main record (probably
one field for integers and one for text strings) separated by some marker.
For example, 2x0x5 for integers or text1&&&text2&&&text3 for text strings.
As each record is processed in the script, use the ASP split funciton to
create arrays of these parameters. At each decision point in the script,
check the appropriate position in the relevant array. Advantage of this
approach: no extra database query for each record. Disadvantage:
unorthodox, un-normalized database design; parameter sequence and meaning of
the values must be documented in the code, which can get messy; and setting
up the parameter strings for each record can be tedious and error-prone.
Overall, it seems to be a trade-off of hygeine vs. performance. Which
approach is better?