How important are naming conventions for getters in Java?

前端 未结 6 1983
孤城傲影
孤城傲影 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:50

    Consider this: Lots of frameworks can be told to reference a property in object's field such as "name". Under the hood the framework understands to first turn "name" into "setName", figure out from its singular parameter what is the return type and then form either "getName" or "isName".

    If you don't provide such well-documented, sensible accessor/mutator mechanism, your framework/library just won't work with the majority of other libraries/frameworks out there.

提交回复
热议问题