I have a class that has a LogOn method.
I'm trying to think what the advantages are two approaches I have.
a) Having a bool returned containing the success of the LogOn.
b) Raising an exception that should be caught.
I thought that exceptions should not really be raised for "expected"
things and since passing, say, an invalid password to the LogOn routine
is something that is bound to happen sooner or later (and is thus
expected), perhaps it should lead to the LogOn method returning false
rather than true.
Also it affects the client side calling code. Should a client expect an
exception from a LogOn method? If so then the programmer also needs to
be aware that that method is "dangerous" and so needs to put a call to
this method within a try/catch block rather than an if block. But I
guess this should go in the documentation for the class that has the
LogOn method ;-)
Ideas anyone? I've currently done it the option a) way but I'm thinking
I should change it to option b).
Flibble