DEV Community

Discussion on: Clean Architecture, 2 years later

Collapse
 
avieramoluy profile image
Agustín Viera • Edited

Elton,
Nice explanation, I'm trying to apply this architecture in my personal projects, but I have 2 questions for you:

  1. Does "usecase" act like as "service" of the previous post or that responsability is from the "manager"?
  2. 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)

Thank you for reading, waiting for your response.

Collapse
 
yvespareteum profile image
yvespareteum

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.

Collapse
 
eminetto profile image
Elton Minetto

Hello Agustín, sorry for the late reply.

  1. 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.
  2. 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.