Context
MVC is an architectural pattern that is used when developing interactive application such as a shopping cart on the Internet.
Problem
User interfaces change often, especially on the internet where look-and-feel is a competitive issue. Also, the same information is presented in different ways. The core business logic and data is stable.
Solution
Use the concept of dividing the concerns to divide the application into three areas
- Model :- Encapsulates the core data and the functionality
- View :- Encapsulates the presentation of the data there can be many views of the common data
- Controller:- accepts input from the user and makes request from the model for the data to produce a new view
The model represents the structure of the data and the operations that can be performed on that data.
The view represents the data that is in a presentable format.
The controller translates the user action like mouse events, submit, keystrokes, words spoken with user input to call the call the specific operation with the model.
MVC example- Java Pet Store
It demonstrates a real-world approach to application development, where the presentation of data is separated from the process of obtaining data from objects which interact with the enterprise or database tier.
The design can be divided into the following tiers:
- Client Tier
- Web tier
- Enterprise Bean Tier
- Enterprise Information System Tier
The Client Tire is the only part which is visible to the end user of the application so it handles the view part it is also connected to the other tiers using some well defined interfaces.
The separate Client tier design provides flexibility and extensibility .