我开始学习 MVP ,但是我有一些关于 Presenter 的问题。例如,如果我有一个非常简单的 Activity ,它仅显示我从另一个 Activity 中获得的一些信息。此刻,我只是显示值,而没有将其发送给 Presenter 。
我是否应该将值发送到 Presenter ,以便 Presenter 调用我的 Activity 中的方法进行显示?还是我可以“忽略” 演示者?
答案 0 :(得分:0)
Should I send the values to the presenter and the presenter will call the methods in my activity to display?
You should.
Or can I just "ignore" the presenter?
You better should not.
One of the benefits of structuring your code using the MVP pattern is the ability to unit test the structural units. Any Presenter should be framework- (in Android, meaning view- ) independent which makes it possible to unit test it. So, if you "ignore" the Presenter you won't be able to unit test the Activity methods invocations.
For commercial app development unit testing is a relevant part.