Naming Conventions: What to name a method that returns a boolean?

Viewed 72292

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?

12 Answers

Generally, methods/functions indicate actions so they should prefixed with verbs. e.g. check, get, make, etc.

The common naming convention for boolean variables is to prefix them with helping verbs e.g. is, does, will, can

I would think that the combination of the two conventions would lead to a pretty good, discerning pattern. So getIsRetreivable() or checkIsRetrievable() would look pretty good to me.

Related