MVC Architecture

MVC is a framework methodology that separates an application's code implementation into three components model, view, and controller. Each component contains different application logics.

Application logics can be categorized into five categories 
  1. Presentation Logic: This is the set of control statements that decides look and feel of an application’s user interface. It is also called View Logic. JSP Pages and Swing/AWT Frame classes can be used to implement view logic. 
  2. Control Logic: This is the set of control statements that decides navigation of View pages of application.  It will conditionally decide which next page will be displayed to the User. Control logic is also know as Navigation logic.
  3. Business Logic: This is the set of control statements that performs business operations. Operation such as fund-transfer, change-password, place an order, and make payment are the examples of business operations.
  4. Data Access Logic: This is the set of control statements which performs database Create, Read, Update and Delete (CRUD) operations. JDBC or SQL calls to manipulate data into the database are called data access logic.
  5. Integration Logic: This is the set of control statements that integrates application with another applications or servers. For example code to integrate SMS server, FTP server, Email server are part of these logic.
Above logic are distributed into three MVC components. View contains presentation logic, Controller has navigation logic, and Model has rest all logic.

Figure : MVC Architecture 

The Model

Model contains persistent data and the business methods to perform business operations on this data and store the data into a database. Ideally one Model represents one RDBMS table. One instance of a Model represents one record of a Table. Model contains business logic, data access logic, integration logic to perform business operations and manipulate database.

The View

  • View components are responsible to render the graphical user interface. User can enter input data using UI input forms or can see application data as different reports.
  • View contains presentation logic and displays data from Model object. If Model data will be changed view will be changed.
  • View gets Model Object from Controller to display data at user interface.
  • View submits its data to its Controller on a user action. A user action is a button click or a menu item selection from the user interface.
Ideally one View has one Controller. When a record contains large number of fields to be displayed on a single UI then these fields are logically grouped and displayed on multiple Views. Since record is one that is why all these Views will have single Controller.  For example when you post your resume on a Job Website, your profile is logically grouped into Personal Info, Educational Info, Technical Info and Work Experience. Four Views are created for these groups and single Controller will handle them.

Views in Web Application are developed by JSPs and Views in Desktop Applications are developed by Swing or AWT.

The Controller

Controllers contain navigation logic and are responsible to perform business operations submitted by View with the help of Model.  Navigation logic are used to determine next View to be displayed after successful or unsuccessful execution of business operation.

The View submits data to the Controller when user clicks on a button or clicks on a menu item from UI. Controller populates submitted data into a Model and calls business method to perform business operation. After performing business operation, Controller forwards control to the next View.

Web applications implement Controller using Servlets. Desktop applications implement Controller using listener classes.