0

I know they say that clean architecture are guidelines, and individual projects will affect implementation, but is there a general thought on the correct implementation? A lot of times I see DTO objects in the application layer, so do you just leave the proto models in the "API" layer and the application layer needs to know about them, or do you basically duplicate those models in both layers, and use translators in the "API" layer so that if the gRPC is ever changed the application doesn't need to?

2

or do you basically duplicate those models in both layers

Yes.

and use translators in the "API" layer so that if the gRPC is ever changed the application doesn't need to?

Exactly.

| improve this answer | |
  • Would that apply to database models as well? Do my domain models need to match my database structure, or can they be different? – Jhorra Aug 23 at 18:34
  • 1
    @Jhorra Both sides have their advantages and dissadvantages. Having same model often results in less than optimal domain model, as you need to fit it into SQL, but it is less work. Separate model requires more code and work, but the models can be fine-tuned for their uses with mapper between them. Personally, I would go for separate domain and database models. – Euphoric Aug 23 at 18:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.