Designing a service/business logic layer that returns useful/consistent messages This is a question regarding design of a service or business logic layer that returns or exposes messages meaningful to the user.

RegisterUser method that takes a user.  What should it return? Should it always return


a Service Information object?
a newly created user?
a boolean, and based on the result, you can interrogate this service's error messages?




public bool RegisterUser(User user)
{
    if (String.IsNullOrEmpty(user.EmailAddress) || !user.EmailAddress.IsValidEmailAddress())
    {
        AddMessage(new Message
        {
            Description = "Invalid Email Address",
            Success = false
        });
    }
    if (String.IsNullOrEmpty(user.Password))
    {
        AddMessage(new Message
        {
            Description = "Password is Required",
            Success = false
        });
    }
    return Messages.Count == 0;
}
The problem with returning a message like this is that you are "hard coding" the messages in the registration method.  If you want to add localization (i.e. return a message in the users language as determined by the culture setting of the client) to the application later it will be much harder.  A cleaner approach would be to use custom exceptions and exception handling.  For example, if the an invalid email address is entered then a InvalidEmailException would be thrown by the RegisterUser method.  The part of the application that calls the RegisterUser method would determine what to present to the user for this type of exception or to percolate it up higher in the application for handling.  This is a cleaner separation of concerns of handling exceptions in the application from what is presented to the user.  This also promotes reuse because different users of the method may want to handle it differently.