How important are naming conventions for getters in Java?

前端 未结 6 2081
孤城傲影
孤城傲影 2021-02-08 10:12

I’m a huge believer in consistency, and hence conventions.

However, I’m currently developing a framework in Java where these conventions (specifically the get

6条回答
  •  半阙折子戏
    2021-02-08 10:59

    If you follow the appropriate naming conventions, then 3rd-party tools can easily integrate with and use your library. They will expect getX(), isX() etc. and try to find these through reflection.

    Although you say that these won't be exposed as JavaBeans currently, I would still follow the conventions. Who knows what you may want to do further down the line ? Or perhaps at a later stage you'll want to extract an interface to this object and create a proxy that can be accessed via other tools ?

提交回复
热议问题