Tutorial List
Home
Interview Questions
Interview
Interview Questions
Links
Web Home
About Us

MVC Pattern




MVC pattern is the first pattern a Java professional heard in his career. This is most widely used patterns. We all use   MVC pattern in our work, but when it comes to define it in interview, it become perplex to express something we use very often. Here we will discuss theoretical aspects of MVC pattern as Implementation will be covered in Struts,

What is MVC Pattern:
MVC is Model View Controller pattern. 
Model: Model is back end of application i.e. DB/DAO layer. This includes   db handling part of your application.
View: View is front end of your application. Everything that end user   interact with, is view. View is implemented using JSP, Servelet, HTML, PHP pages.
Controller: Controller is central component which decide flow of your application. Each request is passed to controller and controller, on looking request type, decides how to handle the request. View  and Model interacts with each other through Controller. When end user make some request by clicking some link on view, a request is passed to Controller and Controller then passes the request to Model. Model retrieves the required data from DB and return to Controller, which then pass the response to View where end user see the result of his action.
Thats how MVC patterns works.
Why to Use MVC:
MVC patterns is used to ensure separation of layer of concern. This separate UI codes from application logic and db access code. So UI people can work on UI part and application programmer can work on business logic while db programmer can write db access code with out bothering about other two team. End of day, they all can assemble their work and project will be ready much before deadline.
Second advantage is, when there is some change needed in any of these layer (UI, Business, DB), other layer remains untouched so there are less chances of rational bugs.
Another advantage is, all the application flow is controlled from one location by controller. This way you can predict the behavior of application in better way and this brings a great flexibility to the application.

I guess you must have got what MVC pattern is. In case of any query, feel free contact me at mohit.amour@gmail.com.

Thanks,
Mohit Singh

No comments: