Important Principles of Model View Controller for PHP Developers

Principles-of-MVC

Model View Controller is a design pattern that governs the fundamental law that both presentation and application logic should be different. Several PHP developers both experienced as well as beginners are curious about integrating MVC into their development script. One of the major obstacle for integration is that no detailed set of information is made available for usage. Moreover, the steps that are available are vague and quite difficult for the beginners to understand. Most of the tutorials would begin with the business logic without explaining the design pattern.

In 1979, Trygve Reenskaung introduced that MVC can be used as a design pattern with Smalltalk. A major ground for all the future MVC architecture has been laid by him in his paper “Applications Programming in Smalltalk-80 : How to use Model View Controller. In other words, MVC is a simple logic for separating both presentation and application logic. The basic idea of MVC is to split the applications into three parts namely- model,view,controller. The controller has direct association  with the View and the Model and so does the view over model. However, model lays inferred association  with view as well as the controller. Inferred associations can be distinguished as associations that might seem feasible from the user’s point of view, but not the actual software design.

The process of interaction:

MVC-Process

  1. Users interact with the “view” by either submitting forms or clicking links.
  2. Controller handles the user inputs by converting the information into model.
  3. Model receives the information and add it to the database to update itself.
  4. The view checks the corresponding updates and responds necessarily.
  5. The view waits for the next interaction from the user.

With regard to beginners of application programming MVC is the best solution. However, separating both presentation and application logic is not a new concept. But whereas in MVC it is more of a streamlined process. Simpler layouts and code presentation make applications maintainable.

Business logic
HighLevelDesign

Business logic usually implies the calculation of logical processes in an application. For example, in case of a calendar, the business logic will be to identify the date, month,day, etc..

Templates

For code reuse facility most of  the MVC’s use templates to enforce DRY. However, major problem associated with these templates is that some are made of complex login and is almost difficult for the beginners who wouldn’t want learning a whole new language. It would be better to choose the best template before development.

DRY

One of the crucial implementations of MVC is dry or “Dont Repeat Yourself” philosophy. DRY is also implemented in Ruby on Rails for code reusability. The principle behind DRY implementation is that changing a single element doesn’t necessarily interface with unrelated elements. For people who find Ruby on Rails, difficult to implement DRY would be a better choice.

Configuration

Convention over configuration is a design paradigm that aims to remove the quality of decision making. It is achieved by setting  up enough framework for convention.

MVC is one of the most popular method of generating clean, powerful, scalable and faster coding with less time and effort. For developers, it would be worth experimenting with few frameworks before sticking with the best one. For further details regarding the development contact us on sales@velrod.in.


About Author

Madhumitha Srinivas

I am an avid reader. My ultimate goal is to convey complex information in a much more simple and interesting form.

For business enquiry, please contact us

TOP BLOGGER

© Copyright 2013 Veltrod Scroll Top