Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

can a entity depend on another entity?

In the "clean architecture", the buissiness logic (entities) is in the core of the application and should not depend on anything.

But now I wonder, if a entity can have a dependency on another entity?

For example in a marketplace application:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

The entity class Product would have following parameters:

class Product(
    int id,
    double price,
    User owner
)

so the owner parameter would be another entity of type: User.

So would it violate the dependency rule?

>Solution :

The dependency rule is about the dependencies between the layers. It states than an inner layer must not depend on an outer layer. I.e. the dependency graph "arrows" must always point inward.

Therefore, one entity can depend on another.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading