jeudi 27 juin 2019

Confusion regarding Entities in Clean Architecture

I am trying to come to a conclusion on whether an Entity-object (as defined in Uncle Bob's Clean Architecture) should be allowed to hold references to abstractions of various sorts. For instance IDataGateway, ILogger or IEventHandler.

My understanding up to this point is that the Entities should be pure application agnostic business logic. In my view this would not allow for the entities to hold such references. But I am now unsure if it should be a rule set in stone.

In his (Robert C. Martin) book p. 190 he states that:

"The Entity object either contains the Critical Business Data or has very easy access to that data".

Does this mean that under some circumstances, the entity can hold reference to a data source (for lazy loading perhaps)?

On the next page, however, he states that:

"This class (...) is unsullied with concerns about databases, user interfaces, or third-party frameworks. (...) The Entity is pure business and nothing else".

What is your interpretation of the term "Entities" in Clean Architecture with respect to abstract references?

Aucun commentaire:

Enregistrer un commentaire