Stuffing executable code in a memo field is an unholy hack. It's a
PITA to parse, debug, or cross-reference. Compilers don't catch simple
syntax errors, error-handlers can't tell you the line of code,
cross-reference won't flag the use of the variables.
If you've got an object oriented system, you use a strategy pattern.
If it's PRG based, you use a switch:
If Customer.PricingStrategy = 1
DO Strategy1
ELSE
DO Strategy2
ENDIF
Well, I think the idea was to avoid having to code, compile, and
distribute a software update every time you need to introduce a new
customer and/or a new variation on the formula.
If you don't like memo fields, it could be done using single rows in
a table closer to the design that Joel suggested. The VFP designers
themselves used memo fields that violate various rules of data
normality to create some of their tools. It seems to work just fine.
VFP's string parsing is ultra fast.
I think the part about syntax errors and the compiler is a
shibboleth. These are simple formulas, they follow a simple pattern.
Only the formulas would be stored to the table. The code to parse
them would be compiled and tested. And if you had an issue with
whether or not a particular new formula might work with the code, a
simple testing routine could be built into the form that is used to
store them to the table, so you could debug them before you store them.
I've always been told that dozens of CASE options or bazillions of IF
ELSE structures is "inelegant" and difficult to maintain. "Do the
simplest thing that could possibly work." What's the simplest way to
accommodate an unknown and unpredictable number of customers who will
want to choose between a relatively small, but not fully known,
number of formula options? Put 'em in a table.
Granted this might become too cumbersome if the universe of formula
patterns gets a lot larger, but that's not the problem that was presented.
Ken Dibble
www.stic-cil.org
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message:
http://leafe.com/archives/byMID/profox/6C.07.04731.05BFB465@cdptpa-oedge03
** All postings, unless explicitly stated otherwise, are the opinions of the
author, and do not constitute legal or medical advice. This statement is added
to the messages for those lawyers who are too stupid to see the obvious.