Javascript – Moving all UI logic to Client Side

Architectureasp.netenterprise-architecturejavascriptteam

Our team originally consisted of mostly server side developers with minimum expertise in Javascript.
In ASP.NET we used to write a lot of UI logic in code-behind or more recently through controllers in MVC.

A little while ago 2 high level client side developers joined our team. They can do in HTMl/CSS/Javascript pretty much anything that we could previously do with server-side code and server-side web controls:

  • Show/hide controls
  • Do validation
  • Control AJAX refreshing

So I started to think that maybe it would be more efficient to just create a high level API around our business logic, kinda like Amazon Fulfillment API: http://docs.amazonwebservices.com/fws/latest/APIReference/, so that client side developers would fully take over the UI, while server side developers would only concentrate on business logic.

So for ordering system you would have a high level API like:

OrderService.asmx

CreateOrderResponse CreateOrder(CreateOrderRequest)
AddOrderItem
AddPayment
-
SubmitPayment
-
GetOrderByID
FindOrdersByCriteria
...

There would be JSON/REST access to API, so it would be easy to consume from client-side UI.
We could use this API for both internal UI development and also for 3-rd parties to create their own applications.

With advances in Javascript and availability of good client side developers, is it a good time to get rid of code-behind/controllers and just concentrate on developing high level APIs (ala Amazon) that client side developers can consume?

Best Answer

Validation on the client side to offload the server side side and increase responsiveness of the application is fine but always do server side validation. One can turn off JavaScript and when using the REST API directly no JavaScript won't ever be needed.