- the data access (typically via a database)
- the business logic (how the data will be used)
- user interaction (how the data and actions will be visually presented)
- Model: This provides the means by which data is retrieved and manipulated.
- View: This represents the visual interface components of the Graphical User Interface (GUI) application which interact with the user. The interaction is of an event-driven nature where actions are initiated via keyboard and mouse.
- Controller: This joins the Model with the View and is the heart of the control logic by associating user-generated events with data actions.
- All actions begin in the view through events generated by the user. The controller provides listeners for the events. The controller also has the ability to manipulate the state of the view objects in a way which offers a response to the events generated by the user.
- The controller interacts with the model by either requesting information from the data source based on user-generated events, or by modifying the data based on these events.
- The model provides the programming interface which the controller must use to access the database, i.e., the controller does not interact directly with the database. In particular the notion of "connection" is never seen in the controller. Furthermore, the model also provides means to avoid, in most cases, direct SQL queries to the database.
- The view interacts with the model only to know about type information and other data abstractions held in the model. The relatively weak link indicates that the View/Model interaction should be "minimal" because the manipulation of data is to be done within the event handlers of the controller.
Model and ORMsThe model provides a data abstraction, presumably so that one can change databases with little or no modifications to the controller code. JDBC can serve as a model in itself because it provides database independence. However JDBC, in its usage of connections and reliance on SQL, is still considered to operate on a low level. It is conceivable that the data source is not a relational database at all, in which case JDBC would be irrelevant.
In general situations, the model presentation is referred to as an Object Relational Mapping (ORM). The selling feature of an ORM is that it provides convenience methods for automatically treating database records as objects and table accesses as class methods. Although it is impossible to eliminate all direct SQL accesses, it is possible to do so for most common database accesses. ORM packages can be of a "homegrown" sort where classes and methods are created primarily as needed to suit the target application, or of a general purpose nature which can fit any application.