MVC Architecture

Model-View-Controller Architecture

  • Design goal : Identify which application component are model, view, or controller.
  • 关系图

upload successful

  • MVC Implementation:
    • Keep the implementation of the three objects types separate.
    • Each type of object does not depend on how the other types are implement.(说白了互不影响)
  • Model Object
    • Represent the persistent information maintained by your application.
    • The information can be kept in a database.
  • View Object
    • View objects represent.
      • Input components of a webpage.
    • Users interact with at least one view object.
    • View object collects information from users in a form that the model and controller objects can use.
  • Controller Object
    • coordinate the model and view object.
    • can be implemented by routing
    • represent application control flows

Route

  • A route is a mapping from an incoming HTTP request to athe appropriate controller code.(说白了就是找路,发来一个http请求,然后route是用来找应该发到哪个controller里)
  • A URI(Uniform Resource Identifier) identifies a resource your application provides.
    • The most common form of URI is a URL

HTTP request

  • Most widely used http method is GET, POST, PUT and DELETE

Form data

  • A user can input data into an HTML form displayed on a client-side web browser.
  • Ways to send form data:
    • Get method.
      • Appended to the target URL
      • Good for small amounts of data
    • Post method
      • sent via environment variables
      • Good for large amounts of data.

upload successful