I have a situation where the business rules have to be applied both on the client and the server. For e.g., lets say the application is creating an bill (or invoice). Now there are lot of tax rules to be applied to the bill.
From a usability perspective it is important to apply all these rules as the user is adding charges or items to the bill and display it to him before saving the bill.
So the tax calculation rules have to be applied on the client.
At the same time, the user should be able to change tax rates and be able to apply new taxes to all the bills that are not yet finalized, which means the same set of rules have to be applied on the server side.
I am stuck with 2 issues -
1) As fas as possible I would not like to repeat the logic. The logic is really complex and over time the 2 will diverge and cause endless maintenance misery.
2) I can think of doing it all on server and doing ajax calls for applying rules and get resulting data as JSON. With network latency kicking-in, this can really kill when a large object and many transactions are involved (think of a user creating or modifying a large bill - upwards of 1000 items and rules are applicable on the entire set of items and not a single item).
My questions - a) Are there patterns which can be used in this scenarios (design / architectural)
b) Are there any tools and techniques that can make one code be used in both client and server without making a network call (Java and Javascript in my case)
Aucun commentaire:
Enregistrer un commentaire