Category: PHP

 

 MVC (Model-View-Controller)

Model-view-controller is a software architectural pattern, which divides a given application into three separate parts. It is basically build to avoid mixing code from the three categories into one class. MVC is one of the most frequently used industry-standard web development framework to create scalable and extensible projects.

In a typical application you will find these three fundamental parts:

  • Data (Model)
  • An interface to view and modify the data (View)
  • Operations that can be performed on the data (Controller)

Architecture of MVC:

MVC

Components of MVC:

Following are the components of MVC:

   1.Model: Model is responsible for managing the data of the application, such as the data, logic and the rules of the application. The model does NOT depend on the controller or the view. It responds to the request from the view and it also responds to instructions from the controller to update itself.

Model classes can either be created manually or generated from database entities. It is the model that responds to requests coming from the view regarding its status or state. In this way, the processing of data takes place only in the model, which ensures internal data consistency.

    2.View: View displays data or the database records. A view requests information from the model, which it needs to generate an output representation. MVC is often seen in web applications, where the view is the HTML page. However it can also be defined to give other view results such as JSON strings and JavaScript code.

The view is also used to present the graphical visualization of the user interface. It could filter out some aspects of the model or highlight others. It represents the input and output data in an interface using various elements such as pushbuttons, menus, dialog boxes, etc. To see the status of the application objects, the view queries the model through the controller.

   3.Controller: The controller is responsible for all the interactions between the model and view. It also responsible for dispatching requests and controlling application flow.

The controller uses the model methods to retrieve information about the application object, to change the status of the object and to inform the view about this change. In a sense the controller enables a user to make changes and see results

 

Advantages of MVC:

  1. Faster Development Process:

MVC supports rapid and parallel development. If an MVC model is used to develop any particular web application then it is possible that one programmer can work on the view while another can work on the controller to create business logic of the web application. Hence this way, the application developed using MVC model can be completed three times faster than applications that are developed using other development pattern.

  1. Ability to provide multiple views:

In the MVC Model, you can create multiple views for a model. Today, there is an increasing demand for new ways to access your application and for that MVC development is certainly a great solution. Moreover, in this method, Code duplication is very limited because it separates data and business logic from the display

  1. Modification does not affect the entire model:

For any web application, user interface tends to change more frequently than even the business rules of the company. It is obvious that you make frequent changes in your web application like changing colors, fonts, screen layouts, and adding new device support for mobile phones or tablets. Moreover, adding new type of views are very easy in MVC pattern because the Model part does not depend on the views part. Therefore, any changes in the Model will not affect the entire architecture.

  1. SEO friendly Development platform:

MVC platform supports development of SEO friendly web pages or web applications. Using this platform, it is very easy to develop SEO-friendly URLs to generate more visits from a specific application. This development architecture is commonly used in the Test Driven Development applications. Moreover, Scripting languages like JavaScript and jQuery can be integrated with MVC to develop feature rich web applications.

Disadvantages of MVC:

  1. The framework navigation can be complex because it introduces new layers of abstraction and requires users to adapt to the decomposition criteria of MVC.
  2. Knowledge on multiple technologies becomes the norm. Developers using MVC need to be skilled in multiple technologies.
  3. MVC needs multiple programmers.

 

Conclusion:

Thus, MVC design pattern is a surely the great approach to building software applications. The MVC framework is easy to implement as it offers above given numerous advantages. Projects that are developed with the help of MVC model can be easily developed with lesser expenditure and within less time too. Above all, its power to manage multiple views makes MVC the best architecture pattern for developing web applications.

 

 

Read More Beginners Guide: MVC (Model-View-Controller)

PHP Web Development

PHP Web Development wordPress

The Model-View-Controller (MVC) is an architectural design pattern that seperates an application in three components : first is Model, second is View, third is Controller.

Here is the flow-diagram of MVC :-

 

MVC-basic.svg

 

Diagram shows the single flow layout of data, how it is passed between each components, and show the relationship between each component works.

Model

The Model component corresponds to all the data-related logic that the user works with.The Model is the name given to the permanent storage of the data used in the overall design.

Model represents shape of the data and business logic. It maintains the data of the application. Model objects retrieve and store model state in a database.

One important aspect of the Model is that it’s technically “blind” – that means the model has no connection or knowledge of what happens to the data when it is passed to the View or Controller components.

Model is a data and business logic.

View

View display data using model to the user and also enables them to modify the data.

The View component is used for all the UI logic of the application

The View is where data, requested from the Model, is viewed and its final output is determined.

In web apps built using MVC, the View is the part of the system where the HTML is generated and displayed.

View is a user interface.

Controller

Controller act as an interface between Model and view components to precess all the incoming requests.

It handles the users request.User interact with View, which in-tern raises appropriate URL request, this request will be handled by a controller.

Controller is a request handler.

Read More What is MVC ?

PHP Web Development

PHP wordPress