Home > OS >  With clean architecture do entities hold properties such a cursors?
With clean architecture do entities hold properties such a cursors?

Time:11-05

I have the following proto message

message ListGamesResponse{
    repeated Game games   =1;
    string nextCursor     =2;     
    string previousCursor =3; 
}

So I have an entity for Game for example. But here I run into a scenatio where I also have cursors. Does this mean that I should make models and entities for responses and requests? In some implementations of this architecture that I used for reference I don't see responses or requests in the domain layer.

How can I avoid having request and response entities in the domain layer? But still pass on the cursors?

CodePudding user response:

In Clean Architecture we would clearly separate between entities which are part of your domain model and request/response objects which are passed to/from the application logic. The request/response objects would be specific to some particular application logic (use case interactor) while the entities are representing "central business rules" which apply to all the use case interactors.

For further explanation check out this article: http://www.plainionist.net/Implementing-Clean-Architecture-Controller-Presenter/

CodePudding user response:

you will need to have an entity of a collection of entities that has the cursors in it for example


    message GamesList{
        repeated Game games   =1;
        string nextCursor     =2;     
        string previousCursor =3;
    }

cause the entity you are dealing with on the domain layer is not just a list of games it's also the state of the list (offset, limit)

  • Related