Name convention on Java Swing components(prefix)

后端 未结 4 1105
忘掉有多难
忘掉有多难 2021-02-06 00:46

An question that was brought to my mind when programming with Swing in Java was, is it a recommendation or an \"official\"/most used naming convention(prefix) on Swing component

4条回答
  •  执念已碎
    2021-02-06 00:57

    I usually hate this sort of thing, because it smacks of Hungarian notation. I don't like the idea of embedding the type in the name of the variable, because if you change types it shouldn't mandate changing all the variable names.

    But in the case of Swing, I guess it's acceptable.

    A good IDE will generate variable names for you. Why not let it? I'd also just spell out the type if you insist (e.g. submitButton instead of btnSubmit). Keystrokes are cheap.

提交回复
热议问题