Index
2015-11-18 06:22 – Ted Roche : Re: Supporting multiple clients with different calculations -- using memo field for varying customer logic??
2015-11-18 08:05 – Ken Dibble : Re: Supporting multiple clients with different calculations -- using memo field for varying customer logic??
2015-11-18 08:16 – Stephen Russell : Re: Supporting multiple clients with different calculations -- using memo field for varying customer logic??
2015-11-18 08:41 – Ken Dibble : Re: Supporting multiple clients with different calculations -- using memo field for varying customer logic??
2015-11-18 09:24 – Stephen Russell : Re: Supporting multiple clients with different calculations -- using memo field for varying customer logic??
2015-11-18 11:54 – mbsoftwaresolutions@mbsoftwaresolutions.com: Re: Supporting multiple clients with different calculations -- using memo field for varying customer logic??
2015-11-18 11:56 – mbsoftwaresolutions@mbsoftwaresolutions.com: Re: Supporting multiple clients with different calculations -- using memo field for varying customer logic??
2015-11-19 09:38 – AndyHC : Re: Supporting multiple clients with different calculations -- using memo field for varying customer logic??
2015-11-19 10:48 – Stephen Russell : Re: Supporting multiple clients with different calculations -- using memo field for varying customer logic??
2015-11-19 13:36 – Gene Wirchenko : Re: Supporting multiple clients with different calculations -- using memo field for varying customer logic??
Back to top
Re: Supporting multiple clients with different calculations -- using memo field for varying customer logic??

Author: Ted Roche

Posted: 2015-11-18 06:22:05   Link

Shibboleth backatcha.

First, the problem was "Customer 1" and "Customer 2" not "dozens" nor thousands.

Second, the question was whether total price included tax on the gross

amount or tax on the cost amount, which *might* vary by state or

locality, not dozens of variations.

I also think the "do the simplest" rule would say: when you first run

into the situation, write and IF statement. When there are three

cases, update to a CASE. When there are too many to handle easily,

promote it to a Strategy Pattern. Solve the problem in front of you.

YAGNI: You Ain't Gonna Need It.

Depending on the exact application and the customers involved, it's

also possible that individual items may be taxed at different rates

(materials v. services v. labor) or that the entire order might be

tax-exempt for other reasons. And what is taxed and in which amounts

may vary by municipality, county, state and country.

All of these are common problems. There are standard "Acceptable

Accounting Practices" of calculating these, and ideally the code ought

to be easily accessible and readable and kept in source code control

(another reason to keep them out of memo fields!) so MB can explain

exactly what is done when he is subpoenaed by the taxing authorities,

or when the customer discovers at the end of the year that they have

not calculated their withholdings correctly.

On Tue, Nov 17, 2015 at 11:16 PM, Ken Dibble <krdibble@stny.rr.com> wrote:

>

>> 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

>

[excessive quoting removed by server]

_______________________________________________

Post Messages to: ProFox@leafe.com

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/CACW6n4t=rrN5K4HofYcEfzQzy7voC3K8TVYp0gqqJBmTvhSk8g@mail.gmail.com

** 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.

©2015 Ted Roche
Back to top
Re: Supporting multiple clients with different calculations -- using memo field for varying customer logic??

Author: Ken Dibble

Posted: 2015-11-18 08:05:20   Link

At 07:22 AM 11/18/2015, you wrote:

>Shibboleth backatcha.

>

>First, the problem was "Customer 1" and "Customer 2" not "dozens"

>nor thousands.

Hm. Maybe we should go back to Mike and get some user stories.

See how much fun pair programming can be?

Ken Dibble

www.stic-cil.org

_______________________________________________

Post Messages to: ProFox@leafe.com

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/21.68.32480.DD58C465@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.

©2015 Ken Dibble
Back to top
Re: Supporting multiple clients with different calculations -- using memo field for varying customer logic??

Author: Stephen Russell

Posted: 2015-11-18 08:16:46   Link

FWIW. There are a limited number of solutions to this correct?

I'd test for a column FormulaType and if present then get that value for

their "process"

Your code base now includes a case statement for that value and does the

correct calculation from there.

Formula in a memo field can get botched either by a file problem or a human

editing one.

YMMV

On Tue, Nov 17, 2015 at 3:31 PM, <

mbsoftwaresolutions@mbsoftwaresolutions.com> wrote:

> VFP9SP2

>

> I've got a legacy app from 2003 that's still in use today and showing no

> signs of changing. Woo hoo! :-) Now for the question. Say you've got

> the following fields:

>

> Cost

> Tax

> Overhead

> Margin (or Markup)

>

> ...and the customers want to do different calculations. Customer Jones

> wants his cost to be calculated this way:

>

> Jones_Total = (Cost * Tax%) + Overhead (% added) on that subtotal, and

> then Markup after that

>

> Customer Smith wants to calculate differently:

>

> Smith_Total = (Cost + Overhead% + Markup) + Tax%

>

> The object variables are all the same, so it's just a matter of

> re-arranging the formula per client's desire.

>

> I'm trying to think of a meta-way of doing this, storing code in the

> database so I don't hardcode anything in the app. Storing the code in a

> TEXT (memo) file and then doing something like EXECSCRIPT or something

> similar.

>

> Suggestions?

>

> tia,

> --Mike

>

>

[excessive quoting removed by server]

_______________________________________________

Post Messages to: ProFox@leafe.com

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/CAJidMYJ7ctPbT8LZHhR2NEXVSFxPM9P8wHv+923hbazbe_zS8A@mail.gmail.com

** 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.

©2015 Stephen Russell
Back to top
Re: Supporting multiple clients with different calculations -- using memo field for varying customer logic??

Author: Ken Dibble

Posted: 2015-11-18 08:41:07   Link

>FWIW. There are a limited number of solutions to this correct?

>

>I'd test for a column FormulaType and if present then get that value for

>their "process"

>

>Your code base now includes a case statement for that value and does the

>correct calculation from there.

>

>Formula in a memo field can get botched either by a file problem or a human

>editing one.

If the problem is finite, then, yes, pre-coded and compiled programs

are the best option. I didn't read the question that way.

If the set of possible formulas is not fully defined and is known to

be likely to change rather frequently, then the formulas should be

stored as data.

As for typos, people put their own formulas into Excel all the time,

and lots more complicated than the ones in this situation, and they do fine.

As for the dreaded memo file corruption problem in VFP, it's easily

and almost completely preventable by good programming practices, and

completely trivialized by good backup practices. I haven't had a

corrupted memo file since the early 2000s.

But I did point out that the formulas could also be stored in

limited-length character fields instead of memos.

Ken Dibble

www.stic-cil.org

_______________________________________________

Post Messages to: ProFox@leafe.com

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/D2.9A.32480.04E8C465@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.

©2015 Ken Dibble
Back to top
Re: Supporting multiple clients with different calculations -- using memo field for varying customer logic??

Author: Stephen Russell

Posted: 2015-11-18 09:24:56   Link

I use a bitwise operation on a column for this type of potential growth.

When defining what goes on a page how many radio buttons do you need?

1, 10, 11, 100,101, 111,...

I can now track that specific text in a db and edit it there. But formulas

for something very specific items like this is a lot more complex.

The try catch around this now needs a lot more work to identify what might

be wrong with "text"

On Wed, Nov 18, 2015 at 8:41 AM, Ken Dibble <krdibble@stny.rr.com> wrote:

>

> FWIW. There are a limited number of solutions to this correct?

>>

>> I'd test for a column FormulaType and if present then get that value for

>> their "process"

>>

>> Your code base now includes a case statement for that value and does the

>> correct calculation from there.

>>

>> Formula in a memo field can get botched either by a file problem or a

>> human

>> editing one.

>>

>

> If the problem is finite, then, yes, pre-coded and compiled programs are

> the best option. I didn't read the question that way.

>

> If the set of possible formulas is not fully defined and is known to be

> likely to change rather frequently, then the formulas should be stored as

> data.

>

> As for typos, people put their own formulas into Excel all the time, and

> lots more complicated than the ones in this situation, and they do fine.

>

> As for the dreaded memo file corruption problem in VFP, it's easily and

> almost completely preventable by good programming practices, and completely

> trivialized by good backup practices. I haven't had a corrupted memo file

> since the early 2000s.

>

> But I did point out that the formulas could also be stored in

> limited-length character fields instead of memos.

>

> Ken Dibble

> www.stic-cil.org

>

>

[excessive quoting removed by server]

_______________________________________________

Post Messages to: ProFox@leafe.com

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/CAJidMYKg1e6uL-nECuoXYo1x9FtTnMVt2N2Jo+dCAdDPzY=hZQ@mail.gmail.com

** 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.

©2015 Stephen Russell
Back to top
Re: Supporting multiple clients with different calculations -- using memo field for varying customer logic??

Author: mbsoftwaresolutions@mbsoftwaresolutions.com

Posted: 2015-11-18 11:54:02   Link

This is EXACTLY what I was wanting. Thanks!!!! While it's nice to put

code in a table memo field so as to get the changes to the customer

easily, that creates a challenge for source code control. My app's exe

version would not change if Customer A's calculation logic changes

(since this is not bundled in the EXE), so my updating routine (which

checks for AppVersion in my Inno setup exe versus the version of your

VFP EXE) would not know the update is needed. Likewise, if you have

multiple installations (on each user's desktop), the challenge

magnifies. To that end, the "store the PRG/FXP in the client's Memo

field in your Companies lookup table and use that for each run of the

EXE" sounds like an appealing route to go, even with the concerns for

source control.

tia,

--Mike

On 2015-11-18 05:26, Alan Bourke wrote:

> To my mind you are looking at a sort of abstract factory pattern.

>

> You have:

>

> Jones_Total = (Cost * Tax%) + Overhead (% added) on that subtotal +

> markup

> Smith_Total = (Cost + Overhead% + Markup) + Tax%

>

> So for Jones have a PRG with a function Calculate(cost, tax, overhead,

> markup) which calculates it his way, and similarly a PRG for Smith with

> a function Calculate(cost, tax, overhead, markup) which calculates it

> the Smith way.

>

> Just supply the relevant compiled FXP to the relevant customer (or even

> all of them to all customers). Then in your application configuration

> DBF or wherever you just store the name of the FXP to use.

>

> CostCalc = "jones.fxp"

>

> In your application startup:

>

> set procedure to (CostCalc) additive

>

> Then you just call Calculate() with your parameters. It will run the

> Calculate() function in whichever FXP you pointed at.

_______________________________________________

Post Messages to: ProFox@leafe.com

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/6ce6f34fe12c86adf6f09a879ad81a27@mbsoftwaresolutions.com

** 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.

©2015 mbsoftwaresolutions@mbsoftwaresolutions.com
Back to top
Re: Supporting multiple clients with different calculations -- using memo field for varying customer logic??

Author: mbsoftwaresolutions@mbsoftwaresolutions.com

Posted: 2015-11-18 11:56:20   Link

On 2015-11-18 09:41, Ken Dibble wrote:

> <snipped>

> As for the dreaded memo file corruption problem in VFP, it's easily

> and almost completely preventable by good programming practices, and

> completely trivialized by good backup practices. I haven't had a

> corrupted memo file since the early 2000s.

>

> But I did point out that the formulas could also be stored in

> limited-length character fields instead of memos.

The backend is MySQL/MariaDB so I'm using TEXT fields.

tia,

--Mike

_______________________________________________

Post Messages to: ProFox@leafe.com

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/3147e0355a3840f4b1598ee6b11b154c@mbsoftwaresolutions.com

** 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.

©2015 mbsoftwaresolutions@mbsoftwaresolutions.com
Back to top
Re: Supporting multiple clients with different calculations -- using memo field for varying customer logic??

Author: AndyHC

Posted: 2015-11-19 09:38:53   Link

create view jonesvw as select .....

create view smithvw as select ...

....

_______________________________________________

Post Messages to: ProFox@leafe.com

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/564DED0D.30906@hawthorncottage.com

** 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.

©2015 AndyHC
Back to top
Re: Supporting multiple clients with different calculations -- using memo field for varying customer logic??

Author: Stephen Russell

Posted: 2015-11-19 10:48:49   Link

On Thu, Nov 19, 2015 at 9:38 AM, AndyHC <jarndice@gmail.com> wrote:

> create view jonesvw as select .....

> create view smithvw as select ...

> ------------

Strike the customer name and use the Real Terminology to express the

outcome.

--

Stephen Russell

Sr. Analyst

Ring Container Technology

Oakland TN

901.246-0159 cell

--- StripMime Report -- processed MIME parts ---

multipart/alternative

text/plain (text body -- kept)

text/html

---

_______________________________________________

Post Messages to: ProFox@leafe.com

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/CAJidMYKSfWdRuxRRtKz_RZtWQbTRy=hHYeG59raRL-Bq2hhPMQ@mail.gmail.com

** 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.

©2015 Stephen Russell
Back to top
Re: Supporting multiple clients with different calculations -- using memo field for varying customer logic??

Author: Gene Wirchenko

Posted: 2015-11-19 13:36:16   Link

At 04:22 2015-11-18, Ted Roche <tedroche@gmail.com> wrote:

>Shibboleth backatcha.

>

>First, the problem was "Customer 1" and "Customer 2" not "dozens"

>nor thousands.

>

>Second, the question was whether total price included tax on the gross

>amount or tax on the cost amount, which *might* vary by state or

>locality, not dozens of variations.

>

>I also think the "do the simplest" rule would say: when you first run

>into the situation, write and IF statement. When there are three

>cases, update to a CASE. When there are too many to handle easily,

>promote it to a Strategy Pattern. Solve the problem in front of you.

>YAGNI: You Ain't Gonna Need It.

Not quite. Let me coin "YMWNNI" (You Might Well Not Need It).

I have had these sorts of situations come up in my client

billing app. Sometimes, the situation gets more complicated sometime

later. Write it so it can be easily changed.

>Depending on the exact application and the customers involved, it's

>also possible that individual items may be taxed at different rates

>(materials v. services v. labor) or that the entire order might be

>tax-exempt for other reasons. And what is taxed and in which amounts

>may vary by municipality, county, state and country.

>

>All of these are common problems. There are standard "Acceptable

>Accounting Practices" of calculating these, and ideally the code ought

>to be easily accessible and readable and kept in source code control

>(another reason to keep them out of memo fields!) so MB can explain

>exactly what is done when he is subpoenaed by the taxing authorities,

>or when the customer discovers at the end of the year that they have

>not calculated their withholdings correctly.

Nicely written.

One thing that has been missing from the posts in this thread

is rounding. round() is your friend.

Sincerely,

Gene Wirchenko

_______________________________________________

Post Messages to: ProFox@leafe.com

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/

** 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.

©2015 Gene Wirchenko