English 中文(简体)
Naming preference: getSupportedModes() vs supportedModes()?
原标题:

I m having hard time deciding which name to choose for my method. I think they both are pretty much self-explanatory, but the latter is faster to type, so, my current preference is supportedModes(). What do you think?

最佳回答

To me, getSupportedModes implies simple retrieval, whereas if there is some actual logic involved to work them out, something like determineSupportedModes or calculateSupportedModes may be better. The name should describe what the function does. Brevity is not a major consideration with modern IDEs with some form of autocomplete.

Different languages also have their own conventions. For example, a function called calculateSupportedModes in Java would normally be called CalculateSupportedModes in C# or VB.

问题回答

I would prefer the more explicit which is getSupportedModes. You don t want other developers to second guess what the method does.

Functions that act on more than just their passed arguments should be named as actions.





相关问题
Naming: solution, projects, namespaces and assemblies

I m working on naming guidelines for solutions, projects, their default namespaces and assemblies (Visual Studio). Now it looks like that: For example, we have a company named "Company" and a project ...

Good name for the opposite of the "canary" metaphor [closed]

The "canary" is a common metaphor (for example in buffer overflow checks) for detecting mis-behaving operations by setting a flag before and verifying that it is still set after. Is there a common ...

Package name for CurrentDate class

I m about to write a class called CurrentDate and need a solid package name. The obvious answers are com.destroytoday.date or com.destroytoday.time, but I m not sure if I ll have more date-related ...

Naming form fields in a web page

How do you name your field names in a web page without revealing the structure of your database tables?

database, table and column naming conventions [closed]

Do you know how to use the naming conventions in mysql database? I ve downloaded a mysql sample database. Here it is: CREATE DATABASE IF NOT EXISTS classicmodels DEFAULT CHARACTER SET latin1; USE ...

热门标签