Suggestions on naming components in java and not only
What should be the convension while naming components and why? E.g
- 开发者_运维问答
myJobButton
buttonMyJob
EDIT: When typing i.e. on netbeans and using code completion with ctrl+space if you choose the second naming convension then typing "button" results on a sorted list of all your buttons.
As long as you're consistent, and as long as it's clear what your identifiers mean, it doesn't matter -- there's no single overarching standard for this sort of thing. If you're working on a project by yourself, do whatever makes the most sense to you; if you're working on a team, settle on a convention and follow it. In general, though, you've got more important things to worry about. :)
I would choose myJobButton
, because it is the way you would call it in English. The other version looks forced and unpleasant to me.
It is much more important that the code is easy to read than that it is easy to write.
have a look here from the sun site.
extract
Variable names should be short yet meaningful. The choice of a variable name should be mnemonic- that is, designed to indicate to the casual observer the intent of its use. One-character variable names should be avoided except for temporary "throwaway" variables. Common names for temporary variables are i, j, k, m, and n for integers; c, d, and e for characters.
精彩评论