Twitter Delicious Facebook Digg Stumbleupon Favorites More

Jumat, 10 April 2009

Models, Views, and Controllers (MVC)

Cake uses the MVC structure as it compiles. What this means is that it e"ectively separates typi-
cal operations into speci!c areas: models for all your database interaction; views for all your out-
put and displays; and controllers for all your commands/scripts.
MVC can vary depending on the framework with which you’re working. But generally it works
like this.

  1. e user interacts with the interface in some way (e.g., presses a button).
  2. E controller handles the input event.
  3. e controller accesses the model to fetch any saved data or fetch data stored in the data-base.
  4. view uses data handled by the controller and model to generate the user interface orany other output that must be sent to the user.
  5. e interface waits for further user interaction before the cycle begins anew.

e bene!t of using MVC structures in developing websites is that repeated functions or tasks can be separated, thus allowing for quicker edits. It can even help in debugging. Say an error keeps occuring during the interaction with the database. Usually the problem will be somewhere in a model, or least likely in the controller (if you follow convention). Knowing that all database interactions occur in just one place makes addressing problems more e$cient.
Cake makes MVC developing a snap and actually has a straightforward folder structure that cuts down on nested folders and extra directories. When deciding between other frameworks, realize that Cake has a more e$cient MVC structure than Symfony or Zend and will occupy less space on your server.

0 komentar:

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Blogger Templates