Can services at the service level interact with each other?

I have a Service Layer in which my PredictionService should know if a specific Race exists. RaceService has a DoesRaceExist() method, but I'm not sure if services can exchange data.

It also leads me to some other problems. Let's say I have a Predictions.aspx page. I implement MVP, so when the page is first requested, the Initialize() method is executed on the presenter. Predictions.aspx requires several pieces of information, from forecasts and from races, maybe even more. Should I ask for all of these things from their respective services or should I query the database only once and get all the information I need at one time? The problem is which service should choose, and then that the service probably does more than just relay what it is for.

What is the best way?

+6
source share
1 answer

If service A needs to get data or run an action on serviceB, it is normal to call serviceB from serviceA.

However, you may find yourself in a situation where services call each other everywhere - if this happens, consider using a facade that organizes different services (so they don’t call each other directly).

+8
source

Source: https://habr.com/ru/post/886537/


All Articles