Thursday, October 10, 2013

What is MVC?

Model–view–controller (MVC) is a an architecture which separates software development complexity into three layers; model, view and controller. A model is a database representation dealing with tables and other database objects. A view is a visual representation dealing with HTML layouts, CSS, JavaScript, form, buttons, etc. And finally a controller is responsible for joining model and view together with certain rules and logic.


With this architecture, a programmer could modify one layer easily, without worrying thinking whether the modifications could affects other layer significantly. For example, with traditional architecture, when you change the database server, let's say from MySQL to PostgreSQL, then you have to adjust all the queries in your PHP code one by one. Imagine how frustrating and exhausting is this. But thanks to MVC, all you have to do is just change the framework's method which deals with database driver, from MySQL to PostgreSQL. And you don't have to adjust all the queries from your PHP code. Isn't this amazing?

0 comments:

Post a Comment