> For the complete documentation index, see [llms.txt](https://ryukiedev.gitbook.io/wiki/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ryukiedev.gitbook.io/wiki/ios/za-xiang/wei-shi-mo-xuan-viper.md).

# 03.为什么选VIPER

## 一: 优点

* 拆分的职责更细,便于编写测试用例
* VIPER内部通过Protocol解耦,能灵活应对变化

## 二: 和MV(X)系列的对比

* 这里的Presenter和MVP中的不同
  * 这里的P并没有主要负责业务逻辑
  * 主要是用来V/I间传递事件,以及管理一些View交互逻辑
  * I承载业务及数据逻辑
  * I的可测试性会更强
* VIPER和MVX相比多了几个要维护的东西
  * View事件管理
  * 数据事件管理
  * 事件和业务的转化
  * 总结每个业务用例
  * 模块内分层隔离
  * 模块间通信

## 三: 好架构应该有的特点

* 能把代码按职责划分解耦
* 可测试性
* 易用,维护成本低,改动成本小

## 参考

> <https://juejin.im/post/5ad1b93d518825557b4d2d44>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://ryukiedev.gitbook.io/wiki/ios/za-xiang/wei-shi-mo-xuan-viper.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
