2

我用 DDD 制作了一个应用程序,我能够制作干净的域层,这些域与其他层明显分开。

但是表示层上的控制器很乱。

即使域被成功分离,ViewControllers 也有多重职责。ViewController 往往具有多种职责,例如

  • 导航
  • 删除
  • 分析
  • 动画
  • 访问多个域等。

通常有许多功能略有不同的 ViewController。

如果尝试使用模板方法制作这些,ViewControllers 的层次结构会变得过于复杂。

如果尝试制作没有模板方法的那些,将会有许多 ViewControllers 共享一些功能。这种方式很容易改变。

有哪些最佳实践?如何在 iOS 应用上构建干净的表示层?

4

1 回答 1

3

In practice, Cocoa MVC often leads to massive-view-controller problem. The solution is to move to a more fine grained architecture like MVP or VIPER.

In MVP on iOS the View is represented by UIViewController (or bare UIView), thus UIViewController is no more loaded with business logic.

MVP

VIPER has even more layers and also solves UI navigation task.

VIPER

于 2016-04-22T13:01:45.550 回答