mardi 21 avril 2020

Best Practice for Composition in Object-Oriented Programming

I work on a mobile app that fetches data from Facebook Graph Api. Where I have the following models: User, User Insights, Media & Media Insights. I thought about this solution which I think it's not the best:

class User{
    List<Media> media;
    UserInsight userInsights;
}

class Media{
    MediaInsight userInsights;
}
  • What I didn't liked about this design is that in order to have a User I have first to create its insights. same thing will happen with the media and media insights.

  • Is it a good practice to have the media list inside the User model or should I keep just the media ids?

Aucun commentaire:

Enregistrer un commentaire