Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

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.

share|improve this answer
    
Yes, validation would also be a part of the Domain/API. Client side would pull what needs to be validated from API or we would document what is required, etc... for each method. If there are still validation errors on submits from client side - we would throw exceptions. –  Mag20 Feb 23 '11 at 11:15

One thing to be aware of is that complex UIs may require an additional "UI assist" layer to support things like hierarchies, master/detail relationships and other UI concepts that don't really exist in the business layer. It's often not possible to implement some of these capabilities w/o making multiple round trips to the business layer, which degrades performance. At least, I prefer having the "UI assist" layer to giving the UI direct access to the database.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.