Take the 2-minute tour ×

I have an interface in c# that helps retrieving of data from a custom archive on server. The interface looks like this:

public interface IRetrieveData
    bool OkToRetrieve(SomeData data); // Method in question...
    bool RetrieveToLocal(SomeData data);

This interface is implemented by the clients that retrieve the data to the local database. There are different flavors of clients that have access to each others data. So, when the processing component calls IRetrieveData.OkToRetrieve right before actual retrieve, the call goes to the client code where the decision is made on whether the data should be retrieved or not. At this point the client can return false and that piece of data is skipped or return true and the processing component calls RetrieveToLocal and send the data to the client which then processes it.

Where I am getting confused is whether to rename the method "OkToRetrieve" to just "Retrieve" or "CanRetrieve" or leave it as OkToRetrieve.

Does anyone have any suggestion?

share|improve this question
add comment

9 Answers

up vote 19 down vote accepted

I think that functions that return boolean value should be named as a yes-no question.

share|improve this answer
I like the is part, but just because it is retrievable doesn't mean it's OK to retrieve it. I would call it isOKToRetrieve –  Thomas Owens Sep 3 '09 at 0:26
Absolutely. The "Is" prefix is a coding standard on our team. –  Rap Sep 3 '09 at 0:28
ALl I would add TO Ariz' answer, (And this is a nitnoi) is to make a distinction as t oexactly what the function is checking... Is it whether the data IS retrievable, or whether the current code CAN retrieve it, or whether it SHOULD rectrieve it, etc. etc. e.g., if the function is examining the validity of the data and 'authorizing the retrieval when the data passes some set of conditions, then IsComplete() or IsValid, or IsTransactionallyConsistent, or something that describes the nature of the check that is being done to 'pass' might be somewhat more informative. –  Charles Bretana Sep 3 '09 at 0:31
@bpayne Uhhh how would you use "Is" for something like shelf.HasProducts() or body.ContainsKnife()? –  mxmissile Sep 3 '09 at 0:33
mxmissile: I would call those methods isEmpty() (and, if the shelf has a limit, isFull()) and I would NEVER make a containsKnife() method, but rather a contains() method that accepts a parameter. And yes, contains() is an exception to the is rule. –  Thomas Owens Sep 3 '09 at 0:37
show 3 more comments

Allways name boolean methods with names similar to questions that can be answered Yes or No.

In your case, CanRetrieve would be a good name (just to use your own suggestion).

share|improve this answer
add comment

Methods mean action. Therefore, I prefer method names to start with a verb. How about?

CheckIsRetrievable(SomeData data)
share|improve this answer
"Is" is a verb... –  Marcel D. Lamothe Dec 1 '09 at 14:38
It depends upon what the meaning of the word 'is' is. –  Night Owl Feb 19 at 2:54
add comment

How about using the prefix 'should'?

ShouldRetrieve(SomeData data);
share|improve this answer
add comment

if you are doing more checks and isRetrievable() isn't appropriate you could use:

share|improve this answer
add comment

In this specific case, I'd probably name it:

public bool IsReady (SomeData)

Because it more clearly demonstrates what will happen once this returns true.

share|improve this answer
add comment

CanRetrieve sounds fine to me. I've seen the Can stem used in Microsoft APIs. The only other real option IMO is IsRetrievable (from Aziz) which somehow seems too linguistically twisted!

share|improve this answer
add comment

I would prefer isOKToRetrieve or isRetrieveOK over variants without "is" under the convention that functions and methods should be verbs.

share|improve this answer
add comment

Depends on your use case. I like to prefix them with words such as 'is', 'does' or 'Can': IsSomePropertySoAndSo, DoesNounSupportFeature and as your example CanVerb

share|improve this answer
add comment

Your Answer


