Google Analytics与MVP设计模式 [英] Google Analytics with the MVP design pattern

查看:142
本文介绍了Google Analytics与MVP设计模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

哪个更好,把google analytics代码放在主持人面前还是保留在活动中?

我认为应该因为View不应该对发送GAnalytics一无所知。视图应该尽可能被动,这意味着它应该只有setter方法来在演示者调用时更新它的状态。

另一方面,我必须连线与GAnalytics的一个大项目与你可以想象的所有可能的行动和我的经验是,从View发送GAnalytics比较容易,因为你可以轻松地跳到按钮/ textView定义,并看到它在UI中的作用,这对于演示者来说是不可能的, t(不应该)引用UI(Activity)中的任何按钮/标签。但那个项目是古老的单片视图控制器(胖活力)架构。这几天我正在致力于MVP(清洁架构),并希望听到关于此主题的其他意见。问候


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

解决方案

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

这篇关于Google Analytics与MVP设计模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆