I'm relatively new to the ideas of MVC and I'm trying to implement them in a web application that I am in the process of designing. From the way I understand it (correct me if I'm wrong) MVC works like this:
- Model: Data and Business Logic
- View: Fairly Self Explanatory
- Controller: Collects user input and uses it to get data from the model (ie application logic)
So for example (bear with me), I am on a page (this will be a view, includes all the html, js and css, and the basic logic to generate said code) and I fill in form X and hit submit. When I hit submit this passes all the form info to the controller. Now there are several things that need to happen:
1. the form info needs to be submitted to the database - this seems fairly apparent to me that this is all handled by the model, even things like data sanitization, and calculations done with the data (as that would be business logic?)
2. an automated email needs to be filled out from a template (eg {name}, {formName} has been filled in by {submitter}) and sent to an admin. This confuses me a little. It seems apparent to me that the filling out of the template would be handled by the model (Business logic?). But what about sending the email? is that considered application logic and thus handled by the controller? I'm fairly vague on the difference between Application and Business Logic and google hasn't really been able to help me.
3. The actions taken are logged in server logs. I think this would be handled by the model as it's dealing with data, but would it be a different model than the one to handle the form info because it's not directly related to the purpose of the app? or does that mean it has to do with the application logic and is thus handled by the controller?
4. The success or failure of 1 and 2 are returned to the user, formatted, and displayed. The Controller would handle the passing of the raw data to the view, where a view formats it and displays it to the user (correct?)
Edit: I'm thinking of using a design similar to Model-View-Adapter rather then the more traditional MVC Triangle
Edit 2: After further reading, is application logic simply a synonym for presentation logic?
Edited by hamalnamal, 19 December 2011 - 01:55 PM.


Sign In
Create Account

Back to top









