Google Analytics with the MVP design pattern [clos

2019-06-17 23:01发布

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

1条回答
叛逆
2楼-- · 2019-06-17 23:45

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

查看更多
登录 后发表回答