Google Analytics with the MVP design pattern [closed]

点点圈 提交于 2020-01-03 09:03:10

问题


Which is better, putting google analytics code in the presenter or keeping them in the activity?


回答1:


I think it should be put in presenter because View shouldn't know nothing about sending GAnalytics. View should be passive as much as it can be, meaning it should only have setter methods to update it's state upon presenter calls.

On the other hand, I had to wire one big project with GAnalytics with every possible action you could imagine and my experience is that it's easier to send GAnalytics from View because you can easily jump to button/textView definition and see it's role in UI which is not possible from presenter because it don't(shouldn't) have reference to any buttons/labels in UI(Activity). But that project was old monolithic view-controler(fat actvity) architecture. This days am working on MVP(clean architecture) and would like to hear other opinions on this topic. Regards



来源:https://stackoverflow.com/questions/36123614/google-analytics-with-the-mvp-design-pattern

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!