I've been brooding over a design issue (smelly code kinda thing) for a couple days now. Maybe you can help.
I have a "Login" Method in my RegistrationService, and currently it looks simplified like this:
public Boolean Login(String username, String password,
out String successRedirectUrl,
out IValidationDictionary validationResults)
{
successRedirectUrl = "";
if (!Validator.IsValid(username) || !Validator.IsValid(password)) return false;
// Other logic
// Distributed login requests etc.
// Build Redirect Url if login was successful etc.
}
Okay, let me explain above code. The method's main return value (Boolean) is supposed to tell the caller whether or not the login request was successful. Now, IF it was successful, I need to redirect the user to a different Url (thus, the "out" parameter successRedirectUrl). If it was NOT successful, I need to tell the user in the view what was wrong - thus the ValidationDictionary (Modelstate).
This code is really ugly and hard to maintain though. I thought of getting rid of the Boolean return type (returning the successRedirectUrl directly and checking on the caller side if it is empty) but I felt things became even more unclear.
Any idea how to do this better?
Thank you!