I'm currently getting my head around solutions for an architecture, in which we develop the client (SPA, Angular) as well as the backend (ASP.net Core). What I'm really interested in is the form of communication between these two parts: REST is almost a given, but would we send fully fledged DTOs or view-dependent ones? Let's say for example, we have the following server architecture: enter image description here

The Controller could just return the IndividualDto, which is more or less the Individual Domain Model, or it could send an IndividualOverviewDto, IndividualDetailDto etc.

This seems to be the way to go, since it reduces the payload size quite a bit, but would also severely limit and couple the client side as well as not having the notion of a Resource. Furthermore, larger applications, like GitHub, usually also offer to access the APIs directly, which would contradict this approach.

I feel like both approaches have their pros and cons, but I didn't find many discussions or other information about this topic. Are there some guidelines or even definitive answers regarding the communication patterns?

  • YAGNI (You Aren't Gonna Need It) - return only data client will need. This will not limit your client, because client don't need it and when it will - you will add extra fields then. Difference between your application and GitHub, that you know exactly what your client going to do and what days it requires. – Fabio Nov 8 at 17:58

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.