Understanding the basic need of MVC architecture

In this post i would like to explain about basic need of MVC architecture while develop the complex applications. What is MVC is explained in my earlier post. I will explain this approach with small example.

Understand the basic need of MVC architecture  by Anil Kumar Panigrahi

Understand the basic need of MVC architecture by Anil Kumar Panigrahi

Target : Identify the Red ball in the box from the three balls ( red, green and white )

Case 1:

In this case all balls are in the one box. Identify the all red balls is very difficult. Here we can find it in the first pick or we have to check the all balls in the box. It is very time consuming. And not easy to identify.

Understanding the basic need of MVC architecture | Anil Labs

Understanding the basic need of MVC architecture | Anil Labs

Case 2:

In this case we have two boxes. First box contains red and white balls. Second box contains green bals.Compare to first case it is easy to identify. But there is confuse in identify the target in first box. Here also we to spend less time compare to first case but spend time to identify. We can find it first pick or check all balls in the box. Here identify the red balls from two balls so it very to identifying.

Understanding the basic need of MVC architecture | Anil Labs

Understanding the basic need of MVC architecture | Anil Labs

Case 3:

In this case we have three boxes. First box contanins red balls, second one is white balls and third one is green balls. It is very easy to identify the red balls in this case. With very less time compare to above two case we can identify. There is no confuse while choosing or identify the red balls.

Understanding the basic need of MVC architecture | Anil Labs

Understanding the basic need of MVC architecture | Anil Labs

 

Now i am applying these cases to PHP development phases.

 

Case 1 : Here we develop the application with combaining the HTML , PHP code along with the Database in a single page.

If we face the bug and we know there is bug in Database, then also we need to check all code to identify that bug in this case. We can identify the bug in starting of code then we feel happy. If we didn’t find that one in the starting of the code then we need to check entaire code. Generally if we combine all code that means we need to check in plenty lines of code.

Example :

Core PHP applications ( Combination of PHP, Database and HTML )
 

Case 2 : Here we develop the applicaion with differenciate the HTML from combination of PHP and Database.

If we face the issue with database then directly go and check in coding part and find the relevent line of code and rectify it. In this we need to check the all coding part. To check the bug took less time compare with the case1. But it also took time.

Example :

Smarty ( Template engine ) – Combination of Coding and Datbase in one part and HTML is in another part.
 

Case 3 : Here we develop the application with differnciate the HTML , PHP and Database.

If we know the bug in database then directly go to the database files and rectify it. It is very easy to identify and rectify it. Easy to understand.

Example :

CakePHP , CodeIgniter

Anil Kumar Panigrahi

With more than 10 years experience in PHP and Founder of Anil Labs, a blog for PHP and related posts. contributed posts regarding CodeIgniter, CakePHP and Learn PHP online ... Contact : [email protected]

You may also like...

9 Responses

  1. Shashi kanth says:

    Thanks for such a nice explanation… really enjoyed it.

  2. Shawn C says:

    Thanks for your explanation, I am trying to show someone how much easier life is with the separation of logic, views and database. This is one of the best ways to explain it that i’ve seen that didn’t make it confusing.

    Thanks

    Shawn
    http://blog.s-vizion.com

  3. gopi says:

    wow..such a great explanation about MVC..really i njoyed with this..thanx for sharing

    Thanks
    Gopi

  4. sravan says:

    Excellent Explanation Anil

  5. Sandeep says:

    Excellent explanation sir with neat diagrams

  6. Vikas says:

    I am not totally agreed with your explanation. This is good to understand the layered programming not the MVC. I would say, this is more relevant to N-tier architecture. Here it is not clear about either Model, View or Controller. Can you please explain what is the role of Model, View or Controller and how it is different from N-Tier architecture.

  7. Punit Advani says:

    Excellent Article!!

  8. Bis says:

    Thanks for sharing – much appreciated! Could you please refer me to your earlier post where you explained whatt MVC is – I can’t seem to find it? Thanks again 🙂

  1. November 21, 2011

    […]  http://www.anil2u.info/2011/11/understanding-the-basic-need-of-mvc-architecture/ […]

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.