Does module hierarchy help with circular dependancy?

Hi there,

At the moment I am working a bit with modules and trying to figure out the best way to avoid circular dependencies. I know that this sort of dependency can be simply “allowed” by requiring modules through an initialization function to allow the modules to execute. However, as I have read, it’s ideal that you don’t have any circular dependencies in the first place.

Instead of bypassing circular dependencies I was thinking in a way to keep the dependency linear. I was thinking of using a hierarchy such as this one:
image

Where basically Module A is the Master Module containing information that is needed by Module B and C eliminating the need to intertwine them together.
The hierarchy can be expanded by adding more “children”.

Does this help with circular dependency?

1 Like

You are correct regarding avoiding circular dependencies. The structure you’re suggesting is called a class tree (one of many names, of course) and if followed as you’ve said, you shouldn’t run into any circular dependencies.

1 Like

Yes it’s kind of very similar to the OOP classes structure which is what I think you are referring to. Thank you for confirming :slight_smile:

1 Like