0

I'm developing Flutter app with my own backend in Spring, but question is rather more general. Let's say I have forum functionality in my app, where I want to display posts, comments etc. Each post / comment was of course posted by somebody and therefore I would like to show his/her name and avatar. Note that I send avatar as encoded string and I decode it on frontend side.

Now I'm asking what in general is good approach:

  1. Should the user info (name, avatar) be part of the PostDTO encapsulated in e.g. PosterInfo or
  2. only user ID is part of DTO and after fetching all the posts I should fetch information about users afterwards? Should I cache it somehow?

Imagine I'm editing the title of the Post. I send an update request and I receive updated one as an response, but again with this relatively big portion of data with encoded picture and again there is a must of decoding it again and so on...

How do you solve such cases in your apps?

invisus
  • 43
  • 3

1 Answers1

1

I would do like this:

(in pseudo code) DTO

class UserDto{
  Posts : List<Post> 
}

So basically every User has his own posts inside ..maybe you can not serialize null poperties (and fill only the field you need)

Dharman
  • 30,962
  • 25
  • 85
  • 135
federico scamuzzi
  • 3,708
  • 1
  • 17
  • 24