Last post Oct 01, 2010 11:53 AM by durgamavu
Sep 30, 2010 10:09 AM|durgamavu|LINK
the differnce between model and controller with some example..thanks in advance.
Sep 30, 2010 12:15 PM|AceCorban|LINK
With regards to your first question, client-side validation happens on the V (or View). As it is client-side, all that code belongs on the View. You could also perform validation on the Controller for all Server-Side validation. As for which way is right
or wrong according to MVC philosophy, I don't know that there is a right or wrong. There is some interesting discussion about it here:
That said, someone makes a good point in that discussion. Even if you validate the data on the client side, you will still probably need to atleast sanitize it server-side to account for malicious users. With a few basic tricks of java-script insertion
in the URL bar up top, a malicious user could potentially do a lot of damage to a web application that doesn't perform atleast some server-side validation/sanitization.
As for the Difference between Model and Controller, Model is your data model and controller is your business logic.
Data model could be a lot of things. It could be a series of text files you save on the web server, or XML files, or a database. The model portion of the MVC is responsible for handling all of your logic to perform the basic CRUD (Create/Read/Update/Delete)
operations on your data model. A well implemented Data model would be written in such a way, that had you decided to change from a database to all XML files, you would only need to change the Data Model with virtually no change in your View or Controller
Controller is the middle-man. It is the brains. It determines what data objects are logically needed and what to do with them. It passes all of those objects off to the View, and processes requests from the View and sends those requests off to the datamodel
to perform them.
The View simply determines how to render the data within those objects in a way that makes sense to the end user.
Oct 01, 2010 11:53 AM|durgamavu|LINK
thanku, it helped