- The model handles application and business logic
- The view handles presentation logic
- The controller accepts and interprets keyboard and mouse input.
The motivation behind MVC was to separate the model code from its presentation. The model code does not contain any UI information, but it broadcasts notification of any state changes to dependents, which are typically views.
This scheme provides a good separation between these three layers but suffers from two weaknesses.
- It has a simplistic view of the model and does not account for any difference between application logic (for example, flow of control and coordination of multiple Web pages) and business logic.
- Most rich-client libraries and windowing system combine the view and controller functions in a single widget, making the logical separation into view and controller less userful.
MVC framework has evolved.
Controller: object handling application logic.
Model:business objects.
Controller
Input Controller
The input controller is a central feature. There is a single input controller for all pages in a Web application. The input controller parses input, determines the parameter-passing mechanisms, extracts any necessay information from the request, cooperates with the application controller to determine the next operatioin (typically called an action), and invokes that action in the correct context. By having a single component as an input controller, any knowledge of HTTP or naming conventions is localized at the request level. This reduces the amount of code duplication and the total size of code. Note that the input controller component is typicaly a servlet, and there may be one instance for accessing the application over HTTP via a regular Web browser and another instance for mobile applications using a Wireless Application Protocol (WAP) enabled device.
Application Controller
The application controller is typically a regular Java object. It coordinates logic related to the application flow, handles errors, maintains longer-term state, and determines which view to display. Application controllers typically need a mapping orequests to the application objects that manage the flow. Most frameworks maintain these mappings in complex XML configuration files.
No comments:
Post a Comment