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.
Target : Identify the Red ball in the box from the three balls ( red, green and white )
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.
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.
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.
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.
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.
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.