![]() |
|
Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re: To auto-calc or not auto-calcby jhourcle (Prior) |
on Jul 21, 2005 at 13:35 UTC ( #476822=note: print w/replies, xml ) | Need Help?? |
It's actually a deeper question as to data normalization-- Some stuff seems redundant, as it can be calculated, but that assumes that the data never gets modified once it's been created, and that there are no special exceptions. For someone who just wants something quick to sell something online, and doesn't care about historical trends and such, calculating on the fly is probably just fine ... But you have to understand that you can never look back up an old invoice in the system. The auto-calculating situation you've described also doesn't allow for item bulk discounts (especially for the complex ones, where it's not just a total percentage off, but the first 1-20 items are full price, but there's a reduction on the 21-100 items, and a further discount on 101+) Even the order total may not just be a straight sum -- maybe there's a discount if you order more than $100 (or whatever currency you're dealing in). I'm all for the calculating it at the time the order, and writing out all of the values, rather than attempting to re-calculate the invoice on what may be different info (price changes, even item description changes, etc.). It's not efficient in terms of size, but it is efficient for speed, and I find it to be more useful in the long term. As for 'correct' -- no one way is more 'correct' than the other other. You have to decide what your requirements and constraints are for the project, and make the decisions based on that. One way is easier to code, and takes much less space to store; the other way will take you longer to write, but gives extra functionality that may (or may not) be useful in the situations your program is going to be used.
In Section
Seekers of Perl Wisdom
|
|