• 0

Server Side vs. Client Side Logic



I do web/mobile development professionally, but there is something that has bugged me for a bit and I was wondering what other peoples opinions are.


For the back-end, I write C#/.NET CORE Web APIs that run on Azure/Dotnet which use EFCore to talk with the database (MSSQL). For the front-end I use Typescript/HTML5/CSS. 


There are things that I can do server side OR client side and am never 100% content with my decision to do one over the other. A quick example would be sending an analytics object. Does it make sense to rely on the API to send down the perfect structured/calculated analytic data for each field or should I send the raw dataset down and let the Typescript do the structuring. To what extent should I do processing/formatting/calculating server side vs. client side?

Should I have the API do the heavy lifting, or let the client take over and let the users pc/device do the work? I know things like basic validation can be done client side without a round trip, but when it comes to the actual JSON objects coming down, is it smarter to just let the API build it fully, or just send down the raw data and let client build it.

Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0

It's always a balancing act when it comes to deciding whether or not you want to strictly rely on server-side processing (especially when it comes to things like validating input), or whether you want to compliment that with client-side validation as well. If you pair server-side processing with client-side processing, the obvious benefit is that in some cases it will avoid the need for more processing to be done on your server than is absolutely necessary. This becomes evident when we are talking about validating user input. Sure, you'll still need to validate them on the server-side, but for a lot of users, you might only need to do this once because there will also be client-side validation to make sure it's extremely unlikely they will submit invalid information.


If you are concerned about the performance cost of making the client do some of the heavy lifting, the browser developer tools are there to help you find out if that's a trade off you would like to make. The main question you should ask yourself is this: does this provide my users with a better user experience? In the case of validating input locally on the client's machine, yes it does. It not only benefits me, but it also means the user gets instant feedback if something's not right.


The first port of call is to check your browser's developer tools to identify the performance difference with and without client-side processing. The obvious things you can check is the time it takes to complete a specific action, and how much memory it consumes, with and without the client-side code.

Link to post
Share on other sites
This topic is now closed to further replies.
  • Recently Browsing   0 members

    No registered users viewing this page.