determining which verb to use for method names in Java

后端 未结 7 2136
半阙折子戏
半阙折子戏 2021-01-30 23:02

I understand that naming conventions are important for a number of reasons, most having to do with making your code more readable and easier to integrate into larger projects, e

7条回答
  •  粉色の甜心
    2021-01-30 23:07

    I think to find anything which could be a "solution" for the problem we should first extract criteria which play any role in choosing name, like:

    • readableness (trivial: getValue instead of transferValueFromThisObjectToYou)
    • convenience (trivial: getCoordValue instead of )
    • semantics of the method (get is not the same as calculate)
    • context of usage (in IDEs I usually type aaa.get_ and press Ctrl+Space to check what I can get from the object)
    • code guides (or other "guides" like Java Bean convention which force you to use some names)

    ...

    However as suat said - better spend some efforts on a documentation for your methods.

提交回复
热议问题