MVC design pattern learning (a)

MVC is also the author for beginners, the main purpose of writing this article is to facilitate their understanding of MVC-related content, some not so professional and comprehensive description, please bear with me.

A, MVC design pattern outlined

MVC full name Model View Controller, the model (model) - view (view) - Abbreviation controller (Controller), and a software design model, with a service logic, data, a method of separating tissue interface display code, business logic to gather a member which, while improving and customization interfaces and user interaction does not need to rewrite the business logic. MVC was developed a unique structure for a conventional mapping input, processing and output of the logic functions in a graphical user interface.

Relationships between model, view and controller can be simply understood as: there are some operations model, the view is displayed to the user to see things, directing the controller is back inside the operation implementation model, the corresponding data and view feedback to the user .

Second, the advantages and disadvantages of the MVC design pattern

(1) Advantages

  • Low coupling
    views and service layers separated, thus allowing to change the view without recompiling the code layer model and controller code, the same change in a business process or a business rule applied only changes to the model layer to MVC.
    The lower the degree of coupling, program modules reusability, portability to more, such program code is more simple and efficient.

  • High reusability
    MVC pattern allows the use of a variety of styles of views to a server with the access code, because a plurality of views can share model. In this case we can provide a more personalized service to users.

  • Fast deployment, low life-cycle cost
    MVC development and maintenance of the technical content of the user interface is reduced. Use MVC model development time to get considerably reduced, which enables programmers (Java developer) to focus on business logic, interface programmers (HTML and JSP developers) to concentrate on the form of expression.

  • High maintainability
    separated view and business logic layer WEB application also makes it easier to maintain and modify

(2) disadvantages

  • Coding complexity
    mean that you want the code is divided into three parts, and there are close links between, there are a lot of business logic needs to be considered. For small and medium such procedures, using general method as not to simplify the code logic.

  • Difficult to debug
    because the model and the view must be strictly separated, which would also bring some difficulties to debug the application, each member is required before use thoroughly tested.

  • Too tight connection and reduces access to view the model view data between the controller and the
    view and the controller are separated from each other, but it is closely linked member, the view of the absence of the controller, its application is very limited, whereas versa, thus obstructing their independent reuse. Depending on the user interface of the model, the view might require multiple calls to get enough data to display. Unnecessary frequently accessed data is not changed, it will also hurt operating performance.

Three, Java web development MVC pattern

  • Model-> JavaBean
    JavaBean Java is a reusable component that can be called Applet, Servlet, SP and other Java applications. It can also be visualized using the Java development tools. It contains the attributes (Properties), method (Methods), events (Events) and other characteristics.
  • View-> JSP
    JSP is Java server pages, you can write Java code in html inside pass jsp.
  • controller-> the servlet
    the servlet program can be executed on the server the above, the intermediate layer between the client domain server.

Here Insert Picture Description

References:

Here Insert Picture Description
2019.12.22

Published 52 original articles · won praise 59 · views 6824

Guess you like

Origin blog.csdn.net/ataraxy_/article/details/103654041