dimanche 26 mars 2017

iOS - News feed app client/server code design

  • Am working on app which will display a list of news feed (posts) returned from the server side, each post will display as (post owner user, title, description, users list who like this post).
  • the app will be news based (not users based)

what is the best design approach to return the the list of posts from the server ??

Suggested options to be discussed:-

1- option (1):-

Each post in the posts list contains (title, description, a list of users who like this post) But the disadvantage of this option is the data for users will be redundant (because may be the same user liked many posts so its object will return in many post)

{
   postsList: 
   [
      title:"title 1",
      description:"description 2",
      postOwnerUser: { user },
      likersUsers: [
                       {
                            userId: "1",
                            userName: "aaa", ...
                       },
                       {
                             userId: "2",
                             userName: "bbb", ....
                        }
                   ]
   ]
}

2- option (2):-

Each post in the posts list contains users ids only, but this needs to make alot of calls to get each user details

3- option (3):-

To cache the users objects in users service for example. but by this we will keep in the memory many users objects may be not useful all the time (we can solve this by clearing the no needed users objects from the cached uses service)

Please share with me the best practices for this design issue or references related

Aucun commentaire:

Enregistrer un commentaire