Difference MVC MVC2 Design pattern

MVC is a design pattern to implement application interface. It represent separation between 3 layers viz. Model, View and Controller which finally present data to the user.

  • Model : Model is set of classes where model objects are associated with creating, editing, and building an application. There could be many resources which can be represented as model i.e. database, Java beans, web service etc. In other works whoever is providing data’s called source and wherever we convert and keep it as an object called Model.
  • View : This is place where formatting model data code and Helpers class to encapsulate view processing logic resides. View could delegates processing responsibilities to many helper classes, implemented as POJOs, custom tags, or tag files. These helpers serve as adapters between view and model and perform processing related to formatting of the logic such as generating an HTML table etc.
  • Controller : Controller defines complete application behaviour and work as initial point of contact for handling all requests which comes from the user. It centralizes all user action to the model where retrieval, invocation of request processing components happens and finally its select view to give reponse to the user.

Differences:

  • MVC1 (Also known as Model 1)
    • Here controller and view both are same (JSP or Servlet).
    • Request directly hit to JSP page which handles complete responsibilities of the request which includes processing the request, validating data’s, handle all business logic and generates the reponse.
    • This pattern was used in initial days of web application development. Where there was no separation between processing request, fetching data’s and redering views.
    • Although this design was conceptually simple but not suitable for large scale application beause many of the functionality was duplicated through out the JSP pages. Unnecessarily there was tight coupling between business logic and presentation logic of the component.
    • Debugging was a big headache becuase all processing logic was included in JSP page.
    • There was little flexibility but no rule to desing separate model to keep data separate. For example: You could directly made call to the database and processing data with business logic

Difference MVC MVC2 Design pattern

  • MVC2 (Also known as Model 2)
    • Complete seperation made between handling the rerquest  (Controller), Processing business logic (Model) and render view for presentation
    • In this architecture only one controller which receive entire requst and taking appropriate action thorugh commnds to send back response to the user.
    • Developer can work separately without interfering each other and do integration whenever develpment is completed.
    • Due to separation of layers,  development time is much faster, duplication of code is very less, debugging and testing is much simpler
    • Very suitable for large enterprise application
    • Application in this pattern is very scalable
    • Reusability of the component
    • Pluggale componnet can easily fit

Difference MVC MVC2 Design pattern

Reference:

Leave a Reply

Your email address will not be published. Required fields are marked *