From Suhrid.net WikiJump to navigationJump to search
- The basic principle behind MVC is that the business logic is not only separate from the presentation, the business logic is not even aware of the presentation. E.g, in a normal business app we can never assume that the business logic will only be invoked from the web and therefore should not place the business logic in say a servlet. It should be in a reusable Java class.
- The model holds all data, state and application logic. The model is oblivious to the view and controller, although it provides an interface to manipulate and retrieve its state and can send notifications of state changes to observers. Typically a model would be represented in a POJO - combination of the business data and the methods that operate on that data. It is the only part of the system that talks to the Database.
- Gives a representation of the model. The view usually gets the state and data of the model from the controller. (Controller puts the model data in a place where the view can find it).
- Takes the input from the user and figures out what it means to the model. E.g., a servlet normally operates in a controller role. Tells the model to update itself and then makes the new model state available to the view (e.g the JSP).