I started looking closer at the upcoming provider model in ASP.NET 2.0 and found some troubling patterns in current incarnation of the API (as of the May 2004 CTP). One example is MembershipProvider.ChangePassword method with the following signature:
public abstract bool ChangePassword(
Can anyone spot a problem? I'll give you a hint, look at the return type. Now, without looking at the docs, can you tell me without a shadow of a doubt what that boolean value indicates? I didn't think so.
In this case, the API follows the old C convention of returning a boolean value to indicate whether the operation succeeded. This convention always felt incomplete to me, and it truly has no place in the world that has structured exception handling, and ESPECIALLY, for a method that should not, under normal circumstances, be a performance bottleneck.
In my opinion, the return type should be void and one should be able to safely assume that under normal conditions the operation will always succeed. Any failure to do so is an exception, and should be handled through the exception mechanism.
posted @ Thursday, June 24, 2004 7:12 PM