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


9 Comments

Shashi kanth · November 19, 2011 at 6:39 am

Thanks for such a nice explanation… really enjoyed it.

Shawn C · November 21, 2011 at 4:15 pm

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

gopi · November 22, 2011 at 4:49 am

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

Thanks
Gopi

sravan · November 25, 2011 at 8:45 am

Excellent Explanation Anil

Sandeep · January 28, 2012 at 5:30 pm

Excellent explanation sir with neat diagrams

Vikas · January 31, 2012 at 8:59 am

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.

Punit Advani · May 28, 2012 at 10:22 am

Excellent Article!!

Bis · October 10, 2012 at 3:41 pm

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 🙂

MVC กับ ลูกบอล 3 สี | OK โอ..เค้ เนวิคุปต์ | คิดจะพูด...พูด โอเค · November 21, 2011 at 8:40 am

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

Leave a Reply

Avatar placeholder

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