This is the question about the flow of UI-interactive execution control in a .net application.
I have a Windows Phone (Silverlight) application.
A UI screen is showing some controls to a user. A user click “upload audio” button, and this triggers an CloudUploadProvider to initialte an upload. CloudUploadProvider in this case is called by the view model (or even I can route the execution request through a thrid-party class instance for correctness, doesn’t matter).
A CloudUploadProvider determines, if it runs for the first time, and if it doesn’t find a cloud account access credentials, it should ask a user to provide some.
Can I just call a Navigate to a cloud account login page from the CloudUploadProvider class, or is it better (architecture best practices-wise) to route the UI navigation request to some other class or even a view model that initiated the upload request.
I am trying to stick with MVVM pattern, but the question I have stumbled upon is whether a “back-stage” BL classes should be allowed to access UI directly?
Having the
CloudUploadProvidercallNavigatefor your application would be quite a hidden consequence for merely initiating an upload! I would instead suggest having theCloudUploadProviderthrow anArgumentExceptionor raise anEventor return directly some error code or message which states ‘Missing Cloud Credentials’. This way, the UI can listen for this message and is in control over what happens when credentials are missing.What happens when credentials are missing doesn’t seem to be the business domain of the
CloudUploadProvider. Instead, it should be the business domain of whatever piece of your application is using theCloudUploadProvider.Just my two cents though – hope this helps!