Tuesday, 8 September 2015

MVC Design Pattern

MVC Architecture

The above diagram shows the MVC Architecture.

Implementation of MVC Architecture

The below diagram shows the detailed view of MVC architecture.

Benefits of MVC

  • Clarity of design
    • easier to implement and maintain
  • Modularity
    • changes to one don't affect the others
    • can develop in parallel once you have the interfaces
  • Multiple views
    • games, spreadsheets, powerpoint, Eclipse, UML reverse engineering, ….

The MVC architecture used by web - based applications is further classified into the following types:

MVC Type – I

Here the view and the controller exist as one entity. In terms of implementation, in the page centric approach the controller logic is implemented within the view i.e. with JavaEE, it is JSP, for all the tasks of the controller like extracting HTTP request parameters, the business logic can be called ( implemented in JavaBeans, if not directly in the JSP), and handling of the HTTP session is embedded within JSP using scriptlets and JSP action tags.

MVC Type – II

The Type – I has the limitations of its lack of maintainability. With controller logic inside JSP using scriptlets, the code can get out of control very easily. Hence, to overcome the problems of maintainability and reusability, the controller logic can be moved into a servlet and the JSP can be used for its real implementation – the view component. Hence, using controller logic within a servlet, the MVC type – II design pattern can be implemented.

The Major difference between type – I and type – II is where the controller logic is embedded in JSP in type – I and type – II it’s moved to servlet.

No comments:

Post a Comment