Generally speaking, should one strive to align a class’s dependencies with its imports?
For example, should one generally avoid doing something like this:
Bar.java:
import com.somepackage.Foo;
import com.somepackage.Baz;
public Bar(Foo foo) {...}
public void doSomething(Baz baz) {...}
Baz.java:
import com.somepackage.Bar;
public Baz(Bar bar) {...}
//etc...
Basically, Bar.java imports/uses/works with something that has it as a dependency, which seems odd.
Although, I’m not sure if classes using their dependents necessarily constitutes some sort of smell (i.e., compile-time dependencies do not line up with run-time dependencies, hinting that some refactoring should probably be done…)
I think this is a design smell. Can you extract a third class that resolves the cyclic dependency? Should one direction of the dependency be decoupled with an interface?
Without details of how the classes depend on each other it will be hard to be more specific.