
Image taken from Blufusion.net
As I’ve mentioned previously, I will be using the MVC design pattern as implemented by CodeIgniter. The key principle behind the Model – View – Controller design pattern is the separation of code from the presentation.
The diagram on the right shows the application flow, which starts with a user request, such as loading a page. This loads the controller, which builds the page on the fly with the help of models, libraries and helpers before sending it to the browser as rendered HTML. Lets take a look at each parts role:
Model
These are responsible for data manipulation, most commonly as a result of interacting with a database. They can also read/write data to/from files, feeds, other web services etc. My using a models, it keeps all data processing such as My SQL in one place, making it easier to maintain.
View
This is what the end user sees. It contains HTML, CSS and JavaScript. These are static files with dynamic data passed in. The only processing and logic you should find here is presentational, such as for loops, basic if/else conditions etc.
Controller
This is where each request starts. It gets any dynamic data it needs from models (and libraries and helpers) before passing it into the view files. Business logic, data validation etc can be found here.
Libraries and Helpers
These are classes and collections of functions which can be used throughout the application. They simplify repetitive tasks such as form validation, image manipulation, file handling etc. These are generally called from the controller, although you can have view helpers, such as CodeIgniters HTML helper.
I just wanted to say that, my fav part of this post is the pic. Nice..