Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting around circular dependency of Android modules? [closed]

I have multiple modules in my android project some of which depend on other modules however I have a couple of cases where modules depend each other thus creating a circular dependency?

How would you generally go about avoiding such cases in an android or java project? In my case I am using Intellij Idea 13.1.2 if that makes any difference?

Many thanks in advance.

like image 461
Apqu Avatar asked May 19 '14 08:05

Apqu


People also ask

How do I get around circular dependency?

To reduce or eliminate circular dependencies, architects must implement loose component coupling and isolate failures. One approach is to use abstraction to break the dependency chain. To do this, you introduce an abstracted service interface that delivers underlying functionality without direct component coupling.

How do I ignore circular dependency?

The Mediator Pattern can also help to lift circular dependencies by encapsulating the bidirectional interaction of two or more objects. The downside of your current code is (besides the circular dependency), that whenever class A changes and also data persistence changes, you have to touch and modify class B.

How can dependency cycle be avoided?

Circular dependencies can be introduced when implementing callback functionality. This can be avoided by applying design patterns like the observer pattern.

How do you fix a circular dependency problem?

To resolve circular dependencies: Then there are three strategies you can use: Look for small pieces of code that can be moved from one project to the other. Look for code that both libraries depend on and move that code into a new shared library. Combine projectA and projectB into one library.


2 Answers

You cannot design modules with circular dependency.If it persist you can merge the dependent code into single module to avoid circular dependency.

like image 130
gyanu Avatar answered Sep 19 '22 11:09

gyanu


There is no magic. You need to redesign your model. Experience and application.

like image 42
RichieHH Avatar answered Sep 20 '22 11:09

RichieHH