Use "Is" prefix for methods with boolean return value

суббота, 26 июля 2008 г. ·

I'm sure that everyone uses methods which return boolean value. First of all you should make sure that these methods can't be moved to properties. If this is impossible you should give a good name to this method. I think that all methods which return bool value should start with Is prefix. Yes, I know that sometime it's difficult to give good name but you should try to do this at least.

Here is a sample how this may look like:


private static bool IsValidAgencyUser(AccountUserEntity user)
{
if (!user.AccountID.HasValue)
return false;
AccountEntity account = ControllerManager.AccountController.GetAccount(user.AccountID.Value);
if (account == null)
return false;
return account.IsLoginAllowed;
}

Обо мне

Моя фотография
Кто к нам с чем и зачем, тот от того и того!