方法的命名建议 - checkSignature 或 isSignatureValid 还是其他?
我有一个方法可以检查请求的签名是否有效。
该方法返回一个布尔值:
_ true:有效签名
_ false:签名无效
我不确定它的最佳名称(也许还因为我不是英语母语人士)。
我不确定:
_ 检查签名
_ isSignatureValid
您认为哪一个更好,为什么或者您有更好的建议。
谢谢,
担
I have a method that checks the signature of a request is valid.
The method returns a boolean:
_ true: valid signature
_ false: signature is not valid
I am not sure about the best name for it (maybe also because I am not an English native speaker).
I am not sure among:
_ checkSignature
_ isSignatureValid
Which one do you think is better and why or maybe you have a better suggestion.
Thanks,
Dan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
isSignatureValid( ... )。它告诉您该方法将返回什么,这很好。另外,就缓存而言,它不会以某种方式做出承诺(checkSignature 对我来说意味着,当我调用它时,您将执行所有数学操作来检查签名,并且您可能不需要重复所有这些工作) 。
isSignatureValid( ... ). It tells you what the method is going to return, which is nice. Also, it doesn't make a promise one way or another as far as caching goes (checkSignature implies to me that you will do all the math to check the signature when I call it, and you might not need to repeat all that work).
我更喜欢
,因为
isSignatureValid()
在语义上没有意义,因为请求不是签名,它有签名。我想您将在if
语句中使用它,所以这不是更有意义吗?此外,如果您想检查
request
本身是否有效,那么这会更合适I prefer
since
isSignatureValid()
doesn't semantically make sense because the request isn't a signature, it has a signature. I suppose you're going to be using this in anif
statement so doesn't this make more sense?Furthermore, if you want to check if
request
is valid itself, then this would be more appropriate