Sunday, December 5, 2010

What is MVC architecture and it's advantages

MVC is Software design pattern use in software engineering, Intension of MVC architecture is provide a flexibility and improve performance of application by separating it in three different layers.
(M) Model 


It is use to manage the data and behavior of application by respond to request of application. Information like (Domain information Model or Application information model) the model object knows about all the data that need to be displayed. It is model who is aware about all the operations that can be applied to transform that object. It only represents the data of an application. The model represents enterprise data and the business rules that Govern access to and updates of this data. Model is not aware about the presentation data and how that data will be displayed to the browser. The model by itself has no visual representation It includes the validation rules, It does not know how to display the information it contains. As MVC architecture the model information can be divided into two categories
Domain information Model
Domain information model includes that information concerned with the 
problem domain for Example if we have railway reservation system so train schedules, prices, Seating arrangement and credit card numbers would domain information.
Application information Model
Application information model is any information that is used by the application but is not part of the problem domain. If Railway reservation is example then error messages is part of application domains. In the information model         change view should automatically change.
Whenever the user sends a request for something then it always go through    the controller. The controller is responsible for intercepting the requests from  view and passes it to the model for the appropriate action. After the action has been taken on the data, the controller
is responsible for directing the appropriate view to the user. In  GUIs, the views and the controllers often work very closely together.
After the action has been taken on the data, the controller is responsible for    directing the appropriate view to the user.
The view provides a visual representation of the information contained in the model, it’s represents the presentation of the application. The view object       refers to the model. It uses the query methods of the model to obtain the       contents and renders it. The view is not dependent on the application logic. It remains same if there is any modification in the business logic. In other words, we can say that it is the responsibility of the of the view's to maintain the     consistency in its presentation when the model changes.
A view depends on the information contained within its model. Examples of views are input fields, text editors, and even entire windows.  
The views know of the model and will interact with the model. View to model  communication and Model and controller to communicate with view via events.
Example,    if a button is clicked an action message might be sent to a model object in order to get something done.         
 Advantages of MVC Architecture:
1. Reusable: 
When the problem recurs, there is no need to invent a new solution; we just have to follow the pattern and adapt it as necessary.
2. Expressive: 
By using the MVC design pattern our application becomes more expressive.
3. Easier support for new types of clients: 
To support a new type of client, you simply write a view and controller for  itand wire them into the existing enterprise model. 
So, that all about MVC , hope it may help you lot!!!
Happy Coding with MVC!!
Thank You
Kirti M Darji