How to avoid a class dependency monolith using Intents in Android?

我们两清 提交于 2019-12-11 18:23:40

问题


As I describe in this question I can not utilize Gradle's incremental compilation properly, as almost our whole codebase is dependent on each other. This causes almost 500 classes to compile all the time.

I found out that many of the class dependencies are caused by the use of explicit Intents like such:

Intent intent = new Intent(context, NewActivity.class);

This creates a class dependency from the current class to NewActivity. Connecting activities in this way quickly form a class dependency monolith. At least a big tree if there are no cycles unless there is something I miss here. (Cycles are common, aren't they?)

I am aware that this may be avoided through the use of Implicit Intents, but as far as I understand this is not the proposed use case for them. In fact, Explicit Intents don't have unnecessary boilerplate code and offer compile-time checks.

I wonder what the proper way is to deal with this issue. Or is this the proper (or at least common) way and incremental compilation is more of a myth among Android developers?

来源:https://stackoverflow.com/questions/54637546/how-to-avoid-a-class-dependency-monolith-using-intents-in-android

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