On Mon, Oct 20, 2008 at 8:14 AM, David FOXWELL <David.FOXWELL@xxxxxxxxx> wrote:
Hi Vern,

Well firstly, although perhaps not so important, I don't see why the function would calculate a total. Surely it
should be returning a tax rate so that the caller would do that calculation. Then when I see type tax I
wonder what else concerning the tax in the future will be needed. Already thinking of all those parameters in
all those programs that would have to be updated. Shouldn't the function be able to access all the taxes for
one product and for each call to another function be able to return the tax rate for the next tax?

No, no, no...

The one thing you don't want to do is return a tax rate and let the
calling function do the calculation. Why would you want to duplicate
the calculation code in all the calling functions?

Ideally, _any_ given calculation/routine/process is only coded once;

Now having said that, let me point out that it'd be perfectly
reasonable to the procedure in question (call it GetTaxes) to return
the data to a caller (call it CalcTaxes) to make the calculation, if
the procedure in question was private and thus used only by the one
caller.

However, I question the need for a procedure as laid out in the
original post. What is the intent behind it? How do you see it being
used?

One thing to keep in mind, one key idea behind modern programming
techniques is the idea of encapsulation. So for example, I might have
public procedures like so:
ORDER_CreateNew(customer_number);
ORDER_AddNormalitem(order_number:item_number);

ORDER_AddNormalitem might call some private/protect functions like so:
CalcTaxes();
UpdateOrderSummary();

Now it seems reasonable, that something external to the ORDER itself,
might need to know something about the taxes affecting an order, so
public functions like:
ORDER_GetTaxesApplied(order_number)

would be useful.


HTH,
Charles

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.