Elton,
Nice explanation, I'm trying to apply this architecture in my personal projects, but I have 2 questions for you:
Does "usecase" act like as "service" of the previous post or that responsability is from the "manager"?
How to structure my project if I want to use an ORM like GORM, ¿which is the appropiate place to put things like "gorm.Model" field and tag "gorm: ..." if its not in the entity.go?
¿Should I create a "DTO" in the repository implementation?
I understand entity shouldnt know nothing about the persistance just like the API (json tags)
DTOs don't go into the repositories. It is on the outside layers it resides, precisely in the "Adapters" layer ; that layer is an enabler to the "Ports" layer, where you have the interactions with the outside world (eg. an API).
The ORM has to be abstracted within the repository.
Yes, UseCase is the Service of the previous post. The Manager is a simpler UseCase, which only handles one entity. I gave different names to make it easier to understand the difference between them.
Conceptually the most "correct" would be to create a DTO, but you can be a little more flexible in that sense and put the tags on the entity. I don't see it as such a critical problem to put the tags on the entity if that makes the project less complex.
Thanks for the positive feedbacks regarding the text.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Elton,
Nice explanation, I'm trying to apply this architecture in my personal projects, but I have 2 questions for you:
Thank you for reading, waiting for your response.
DTOs don't go into the repositories. It is on the outside layers it resides, precisely in the "Adapters" layer ; that layer is an enabler to the "Ports" layer, where you have the interactions with the outside world (eg. an API).
The ORM has to be abstracted within the repository.
Hello Agustín, sorry for the late reply.
Thanks for the positive feedbacks regarding the text.