命名约定:什么命名一个返回布尔值的方法? [英] Naming Conventions: What to name a method that returns a boolean?

查看:140
本文介绍了命名约定:什么命名一个返回布尔值的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在c#中的接口,帮助从服务器上的自定义存档中检索数据。该接口如下所示:

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);
}

此接口由将数据检索到本地数据库的客户端实现。有不同风格的客户端可以访问彼此的数据。因此,当处理组件在实际检索之前调用IRetrieveData.OkToRetrieve时,调用将转到客户端代码,在那里决定是否应检索数据。此时,客户端可以返回false,并且该数据块被跳过或返回true,并且处理组件调用RetrieveToLocal并将数据发送给客户端,然后客户端处理它。

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.

我感到困惑的是是否将方法OkToRetrieve重命名为Retrieve或CanRetrieve或将其保留为OkToRetrieve。

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

有人有任何建议?

推荐答案

IsRetrievable()

我认为返回布尔值的函数应该命名为yes-no问题。

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

这篇关于命名约定:什么命名一个返回布尔值的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆