Re: Your opinion please



Hi Lucian,

You should provide a method or property that allows the calling code to
check whether credentials are required so that it may prompt the user for
them, if necessary, and avoid an exception. A method named,
"RequiresCredentials" or a property named, "CredentialsRequired" sounds
reasonable to me.

I don't know... Think of this code:

bool isreq = db.CredentialsRequired();
if (isreq) db.Login(GetLoginInfo());
db.Access();

I envisioned the code to look more like this:

Database db = new Database(connString);

bool secure = db.RequiresCredentials();

// or
// bool secure = db.CredentialsRequired;

if (secure)
db.Open(GetUserCredentials());
else
db.Open();

Where's the problem here?

What happens if an administrator imposes a security requirement while
this thread is just part way through? Then the db.Access() call will
fail with the access fault. So you're going to need to handle the
access fault in any case.

Multi-threading issues are an entirely different thing to consider. I
assume that the Database class will be immutable in that respect. It
doesn't make sense to change whether or not a connection requires
credentials asynchronously, IMO.

--
Dave Sexton


.