UPDATED:
I have a desktop application, with the following components interacting:
- Winforms UI.
- Service (in-process C# class that contains business logic to actually do stuff).
- Controller (C# class that coordinates events raised by the UI and calls service methods).
If a controller asks a service to do something, but that service needs something more from the controller first (i.e. data that the controller must use a UI to obtain from the user), how should the service get the controller to do so?
I'm comfy with the concept that
- User communicates with
- UI which communicates with
- Controller which communicates with
- Service component (not to be confused with a web service or out-of-process service) which communicates with
- Data/Repositories which comm...
and so on.
However, with regard to the Controller communicating with the Service, what method is best for this? Should:
- Service methods be fairly fine-grained, and throw exceptions if something's not right so the controller knows whether to move on or tell the user something went wrong? Or...
- Service methods return objects that the controller can inspect to decide what to do next?
I like the first option, because the second could mean class-explosion, where you need a ServiceResult
-style class for each Service method.
I ask because of course the Service component cannot tell the UI what to do, only the controller can, but the controller doesn't know what to tell the UI without getting some feedback from the Service.
What do you think?