clean-architecture

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:

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.