문제

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top