I am refactoring a large codebase where most of the classes are located in one package. For better modularity, I am creating subpackages for each functionality.
I remember learning somewhere that a package dependency graph should not have loops, but I don't know how to solve the following problem: Figure
is in package figure
, Layout
is in package layout
, Layout
requires the figure to perform layout, so package layout
depends on package figure
. But on the other hand, a Figure
can contain other Figure
s inside it, having its own Layout
, which makes package figure
dependent on package layout
.
I have though of some solutions, like creating a Container
interface which Figure
implements and putting it in the Layout
package. Is this a good solution? Any other possibilities?
Thanks