Saturday, 28 September 2013

Introduction to MVC Architecture and it's Benefits

MVC (Model-View-Controller) is a software architecture,or design pattern which is used in software engineering. The principle of MVC is  separation  the "presentation logic" from the "business logic".  MVC design pattern have some rules, that should be followed by the programmer to produce clean, scalable, powerful, fast code in the least amount of time with the least amount of effort.


The MVC principle is to separate the application into 3 main parts
"Model" ,"View","Controller"


Model 

Model is the most important part  of MVC .It is responsible for the business logic of he software application like the database logic, main logic of the application etc. End user does not bother about this logic,model doesn't interact with the end user.


View

View is responsible for the presentation  logic of the application , it represent the output   to the user.
it obtains data from the model and presents it to the user.

 
Controller

Controller is responsible for communication between model and view it send commands to the model to update the model's state (e.g., updating database). It can also send commands to its associated view to change the view's presentation of the model (e.g., Present the updated view).

 

Benefits of MVC

 

Substitutable user interface
 
Different views and controllers can be substituted to provide alternate user interfaces for the same model. For example, the same model data can be displayed as a bar graph, or a pie chart, or a spreadsheet.

Multiple simultaneous views of the same model
Multiple different views can be active at the same time. Each view simultaneously and independently presents the same information from the model. This applies more to GUI MVC than web MVC. 

Syncronized views
 The change propagation mechanism insures that all views simultaneously reflect the current state of the model.

Easier user interface changes 
Changes affecting just the user interface of the application logic become easier to make.

Easier testing
With MVC it can be easier to test the core of the application, as encapsulated by the model.

 




 

 








 

No comments:

Post a Comment