Reputation: 5236
I'm just learning how to write applications using the WCF RIA Services. Most tutorials on the topic go upto fetching data from a database and displaying it in the client. I am not clear on where I should be placing my business logic. I essentially need to take input from the client, perform a few queries to the database, then perform some computations on it and display the result of the computations on the client. Do I retrieve data from the database to the client and perform the operations there, do I perform the operations at the server's domain class and return the result or something else?
Any help is appreciated
Upvotes: 3
Views: 237
Reputation: 9478
You can do it on the server or client but doing it on the client allows you to use the client machine/processor to perform the computations. If there are a large number of users, pushing work onto the client can make a big difference in server performance.
Upvotes: 1
Reputation: 8670
The idea behind WCF RIA Services was that your business logic can be shared across both the client and the server. Obviously you can't build in complex calculations, but all of your validation and rules around business classes should be in the object metadata so that it shows up on both the client and the server automagically.
The most important thing to remember when doing these types of calculations is that:
1) Any code you send down to the client can be viewed by the client. 2) Any calculations done on the client could be (potentially) changed by the client.
So if you have an order service and calculate the order total only on the client, a malicious user could send you an order with a miscalculated total.
Upvotes: 0
Reputation: 2018
Performance is one consideration, but you must also consider your IP. Remember a Silverlight application is delivered to the client, and all the .Net code on the client can be re-engineered. Yes you can obviscate (sp!) the code, but that is a an extra step in the deployment. Regardless, if you IP is valuable, I would recommend that the data collection and valiation be done on the client (this is simply good practise anyway). After the work is back to the server, you can inject/intercept the the WCF RIA Services request and peform "additional" work. I asked a simliar question here: ChangeSet Complete
Upvotes: 0