consider SPA application which uses centralized store like ngxs or vuex. Are there some recommendations about response of REST API? Any specifications where I can read more about that?

For instance, I have domain object ObjectA which has about 12 fields. In case when I need show collection of that object in table grid (only name field) should I return whole that objects with all fields from REST controller or return only list of strings?

In my previous app I always fetch whole objects. When I had objects ObjectA and ObjectB where one of fields of ObjectA has type ObjectB. Instead of creating DTO for that purpose which I adjust to hold only 1 required field of ObjectB I put whole ObjectB in response and store it in vuex as is.

Which way do you prefer or which is recommended? Sending and work with whole objects when you need 1-2 fields of that object at the expense of greater payload or always break objects and send only fields which I need? Thank you in advance!

  • I prefer the way that works best for my specific situation. – Robert Harvey Jan 14 at 18:23
  • The simplest one that best fit in the needs. Make it sophisitcated later. If need it. – Laiv Jan 14 at 21:37
  • @RobertHarvey so there is not recommended way? – Denis Stephanov Jan 15 at 8:42
  • @Laiv same question as above. – Denis Stephanov Jan 15 at 8:44
  • 1
    @DenisStephanov Software Engineering is not a precise or exact science. Literally, there could be countless ways (solutions) to achieve the same results. What makes one solution to stand out the others is its adequacy. Adequacy is dictated by our specific requirements, needs and personal preferences. There are no right or wrong solutions if they solve the problem. There're only trade-offs. We can not say which trade-offs best fit in your priorities. My previous comment is a bit of common advice. Start with the simplest or neatest solution. – Laiv Jan 15 at 9:05

Your Answer

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

Browse other questions tagged or ask your own question.