Question

A user requests latest news , the news get data from multiple sources (posts, users , photos, comments) . How would you model the news?

Is it good to have a gateway that couples these tables + a service that gets the data from the coupled gateway and handles the data as a response ? Or a domain model that couples the other models (this would mean to add in one of those gateways a joined long query that , in my opinion needs a separate gateway ).

Was it helpful?

Solution

I would create a NewsService, as it would be coordinating the creation of the news, but would defer any specific responsibility to the appropriate model. If it's a news feed, like in facebook, I would create another model, NewsItem which is created upon the entry of a new post, photo etc. This way, the responsibility of build the news would fall more into your domain model and your NewsService would be really just orchestrating the construction of the list. You could even, depending on your app, just use a NewsRepository.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top