graveeel
241
6
Vue

Best practice for Calculations

Posted 1 year ago by graveeel

Hi all, I'm currently re-thinking my code and searching for some smart best practice solutions.

I'm using Vue for Client Usability stuff like invoices etc. My current issue is the calculation of total and subinformation. Currently this information is calculated directly in vue to keep it fast.

Now I want to offer an API which auto-generates some of the information, calculations etc. that is normaly calulated on client site. Basically I have to recode every calculation that is possibe on client site on server site and maintain both.

For Example you have an Invoice and 7 items which will be added. Each items that will be added sums up to a total value.

Client Example:

  • All Calculations will be maintained in vue and total sums etc. will be stored when saving/ updating to the database without server calculations.

Server Example:

  • Each time the user adds an item everything is send to the server, being calculated and send back to vue. Vue would do no caluclations and just display the outcome.

Now my question: How would do you handle this kind of requirements?

Would your rather send a server request for each update/ calculation and keep everything on serversite or maintain both solutions?

I'm kind of concerned about performance issues when going with server solution only, but on the other hand this would be my prefered solution to keep maintenance simple.

Any other ideas!?

Thanks, Graveeel

Please sign in or create an account to participate in this conversation.