I have a Service Layer, in which my PredictionService needs to know if a certain Race exists. The RaceService has a method DoesRaceExist()
, but I am not sure if the services can communicate.
That also leads me to some other problems. Lets say I have an Predictions.aspx
page. I implement with MVP, and so when the page is first requested, the Initialize()
method in the presenter runs. The Predictions.aspx
needs multiple pieces of information, from predictions and from races, maybe even more. Should I ask all these pieces from their appropriate services, or should I query the database just one time and get all the information that I need in one go? The problem is then which Service to pick, and then that the service probably does more than just relaying what it is intended for.
What is the best way to go about?
If serviceA needs to get data or run a action on serviceB, it is fine to call serviceB from serviceA.
You might, however, find yourself in a situation where services call each other all over the place - if that happens, consider using a facade that orchestrates the different services (so they don't call each other directly).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With