Naming suggestion for a method - checkSignature or isSignatureValid or something else?
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 validI am not sure about the best name for it (maybe also because I am not an English native spe开发者_JAVA百科aker).
I am not sure among: _ checkSignature _ isSignatureValidWhich one do you think is better and why or maybe you have a better suggestion.
Thanks,
DanisSignatureValid( ... ). 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).
I prefer
hasValidSignature()
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 an if
statement so doesn't this make more sense?
if (request.hasValidSignature()) {
...
}
Furthermore, if you want to check if request
is valid itself, then this would be more appropriate
if (request.isValid()) {
...
}
精彩评论