Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does a method name starting with "Does" look good?

Is it a good practice to start a method name with "Does" (in C#)? It looks a little bit weird to me, so I would like to get your opinion.

I am writing a method which check if an account exists or not, should the signature be "bool DoesAccountExist(id)"? Is there a better name?

Thanks!

like image 427
Martin Avatar asked May 04 '11 17:05

Martin


People also ask

Can method name start with is?

For methods or properties that return a boolean, it can be useful to use a naming convention where the method begins with the word "is". If you use "is," you'll have to rephrase the rest of the method name so that it makes sense to the reader.

What makes a good function name?

The name should clearly, without ambiguity indicate what the function does. You don't have to jump around searching for the truth. Function names should apply the lower camel case form: addItem() , saveToStore() or getItemById() . Every function is an action, so the name should contain at least one verb.

What can Java method names start with?

Java method names By convention, method names begin with a lowercase letter. The method names are verbs or verbs followed by adjectives or nouns. Each subsequent word starts with an uppercase character.


1 Answers

Personally I'd go with AccountExists(id) in this case, since it will look more natural in an if block

if (AccountExists(id)) { }
like image 68
Patrick Avatar answered Oct 11 '22 13:10

Patrick