Hi. I'm building a system such that I have a processing engine that does a lot of complex calculations and a user interface that can be used to access that engine. Typically, the processing engine will reside on a powerful machine while the interface might be on a separate machine (and use sockets or some distributed communications to communicate).
My question deals with tradeoffs of the model view controller pattern here. Just by the nature of the system I have a clear separation of logic and presentation. But, I'm wondering if I should be keeping a data "model" as part of the user interface software in addition to the processing engine (note the processing engine can retain state and is not just for straight calculations).
By maintaining this model, I may have some data duplication and storing state that may already be stored in the processing engine. But, I also don't want to have to query the remote processing engine if I don't need to. One particular issue that comes to mind is data validation. I don't want to send a message with invalid data to the processing engine remotely just to get a message back saying the data was bad. But, if I do validation on the client side, I have an issue if someone wants to use the processing engine without the client since the validation will not be there. Lastly, I also will end up some data duplication because I need to store state information that is in the processing engine just to do the data validation on the client.
I know this is a pretty long winded post, but any advice would be appreciated here.
Redundant data validation is common. I validate my data on the client in order to let users know immediately when data is invalid, but my server-side code never assumes that client-side validation takes place.
And of course, there are some validations that can only take place at lower levels and aren't checked at the client (authentication, for example). [ June 15, 2008: Message edited by: Bear Bibeault ]
A little redundancy is not bad. Never trust the client. Always validate the data, even if it appear redundant in the first release, you never know what sort of Web Service it will turn into, and then you must re-edit.
Plus, if the client is a browser, you can never trust the browser. Ever.