知识库 知识库
首页
  • Hyperskill - Java

    • Java basic
    • Java OOP
    • 应知
    • 扩展
    • IO & Stream
    • Error & Exception
    • Algorithm & Data structure
    • Design pattern
    • Web
    • Spring boot
  • 练习题

    • 选择题 & 填空题
    • 代码题
  • Frank - Java与生活 (OOP)

    • 参考资料
    • Java基础
    • OOP上半部分
    • OOP下半部分
  • Frank - Java API进阶

    • Base API
    • Unit Test and main function
  • 学习笔记
  • 学习笔记

    • 数据库
  • Frank - MySQL删库跑路

    • 安装、连接、配置
    • 基本操作——数据库
    • 基本操作——表
    • 基本操作——数据
    • 数据类型
    • 列属性完整性
    • 数据库设计思维
    • 单表查询
    • 多表查询
  • 学习笔记

    • 其它
  • Frank - Linux现代方法

    • 必知
    • 命令
    • 技巧
  • 技术文档
  • Git
  • GitHub技巧
  • 前端
  • Khan Academy - 语法
  • Monthly
  • 阅读
  • Others
  • 学习
  • 面试
  • 心情杂货
  • 实用技巧
  • 友情链接
收藏
  • 标签
  • 归档
GitHub (opens new window)

Jim FuckPPT

Java小学生
首页
  • Hyperskill - Java

    • Java basic
    • Java OOP
    • 应知
    • 扩展
    • IO & Stream
    • Error & Exception
    • Algorithm & Data structure
    • Design pattern
    • Web
    • Spring boot
  • 练习题

    • 选择题 & 填空题
    • 代码题
  • Frank - Java与生活 (OOP)

    • 参考资料
    • Java基础
    • OOP上半部分
    • OOP下半部分
  • Frank - Java API进阶

    • Base API
    • Unit Test and main function
  • 学习笔记
  • 学习笔记

    • 数据库
  • Frank - MySQL删库跑路

    • 安装、连接、配置
    • 基本操作——数据库
    • 基本操作——表
    • 基本操作——数据
    • 数据类型
    • 列属性完整性
    • 数据库设计思维
    • 单表查询
    • 多表查询
  • 学习笔记

    • 其它
  • Frank - Linux现代方法

    • 必知
    • 命令
    • 技巧
  • 技术文档
  • Git
  • GitHub技巧
  • 前端
  • Khan Academy - 语法
  • Monthly
  • 阅读
  • Others
  • 学习
  • 面试
  • 心情杂货
  • 实用技巧
  • 友情链接
收藏
  • 标签
  • 归档
GitHub (opens new window)
  • Hyperskill - Java

    • Java basic

    • Java OOP

    • 应知

    • 扩展

    • IO & Stream

    • Error & Exception

    • Algorithm & Data structure

    • Design pattern

    • Web

      • Theory:World Wide Web
      • Theory:HTTP
      • Theory:HTTP URL
      • Theory:HTTP messages
      • Theory:MVC
        • What are MVC and MVC components
        • Advantages and disadvantages of MVC
        • Conclusion
      • Theory:Introduction to Spring Web MVC
      • Theory:REST
      • Theory:Postman
      • Theory:Getting data from REST
      • Theory:Posting and deleting data via REST
      • Theory:REST Exception handling
      • Theory:Handling requests with bodies
      • Theory:Domains
      • Theory:HTTP Basic Auth
      • Theory:IP
      • Theory:Authentication and Authorization
      • Theory:OAuth
      • Theory:Java 11 HTTP client
    • Spring boot

  • 练习题

  • Frank - Java与生活

  • Frank - Java API进阶

  • 学习笔记

  • Java
  • Hyperskill - Java
  • Web
Jim
2022-07-20
目录

Theory:MVC

When developing web or mobile applications, programmers use different patterns to make their code simpler and easier to work with. MVC is one such pattern. It describes how to separate the user interface from the business logic and data access logic. That way the user interface can be modified independently, so there is low coupling between the different parts of the application.

After reading this topic, you will learn about the components of the MVC pattern, as well as its advantages, and also consider when it is not a good idea to use MVC.

# What are MVC and MVC components

MVC (Model-View-Controller) is an architectural pattern separating an application into three logical components:

  • Model is responsible for all data and its related logic;
  • View is responsible for presenting data to users or handling user interaction;
  • Controller informs the Model of the need for changes.

In order to understand how to work with these components, consider the example below.

img

When the user clicks on interface elements, they interact with the Controller. The Controller accepts user input and interacts with the Model. The Model represents the state of an application. It can be data in a database, a file, an in-memory data, or something else. After modification, the Model updates the View, and its user sees this.

提示

This describes the most basic version of the MVC architecture. There is also a common variant where there is a connection between View and Controller. The Controller in such cases provides the interconnection between the Model and View components.

# Advantages and disadvantages of MVC

MVC has become a sought-after pattern and has been widely used because of its benefits:

  • By separating into components, the flexibility, maintainability, and scalability of the application are increased.
  • You can test components separately from each other.
  • The components can be reused.
  • Models can have multiple views.
  • MVC allows you to configure different levels of security for different components.

And these are the disadvantages of the MVC pattern:

  • One should keep in mind that it is not suitable for small applications. It makes simple applications more complex.
  • MVC is also not suitable for high-performance applications. Sometimes it's more efficient to go through several layers of architecture.

提示

MVC is not the only architectural pattern. This is worth bearing in mind if, for some reason, it is not suitable for the development of your application. There are several other patterns for similar needs: MVP(Model-View-Presenter), MVVM(Model-View-ViewModel). The MVC, MVP, and MVVM patterns are often called the MV* family.

# Conclusion

MVC is an architectural pattern that separates the user interface from business logic and business logic from data access logic. It has its pros and cons, and many implementations and interpretations. It's interesting to know that this pattern was originally used for desktop graphical user interfaces. Currently, MVC is used in the development of web applications and mobile applications. Therefore, its knowledge will be handy for you in the future.

编辑 (opens new window)
#Framework#MVC#Web
上次更新: 2022/10/12, 17:01:25
Theory:HTTP messages
Theory:Introduction to Spring Web MVC

← Theory:HTTP messages Theory:Introduction to Spring Web MVC→

最近更新
01
《挪威的森林》
04-14
02
青钢影
04-14
03
Processing strings
02-18
更多文章>
Theme by Vdoing | Copyright © 2022-2023 Jim Frank | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式