I have an application that needs to load data via web service calls and perform various permission and data checks. Fairly typical. I'm currently doing this in the background when the application starts, however it is a wizard type application and so the user can't do much until all of this has completed. If any issues come up when doing this I want to present the user a helpful message (you are "missing permission x" or "failed to retrieve y").
For the following, understand that I can change how I'm going about doing something, but I can't change what steps I need to perform. This has been simplified down as well.
A typical item might go like this. I need to retrieve a list of groups the user belongs to. However, first I need to check if the user has permission to view this list of groups otherwise the other call will fail. Once I have the list, I then need to check whether they have certain permissions within each item and discard those that don't apply. If they don't have permission in any of the groups, inform the user.
Initially I had everything in a LoadAndCheck() type call to work out all the various items I needed. Obviously this is large an clunky.
I then moved to a breaking each step up into pattern where each item was in a class behind an interface
interface IInitialize {
bool InitializeAction();
void OnFailure();
}
(i.e. CheckThisPermission, LoadThisList, CheckThatPermission). Each class performed a small action and if that action failed (loading data) or was false (permission check) it contained the step to perform to inform the user of the issue.
I can then loop through these classes and on failure of one step, not perform the following steps and have things configured to inform the user. This also lends itself to DI down the road if I settle on this pattern.
However, something just doesn't feel right about this pattern, though it is better than everything in one big call. Maybe it's just the name I'm giving to things. However my brain is wiped out and I'm not coming up with anything better.
So do you have any good patterns for doing something similar when starting up your application?