Android Performance - 'Avoid Internal Getters/Setters'

前端 未结 7 764
情歌与酒
情歌与酒 2020-12-08 07:45

Just read this on the dev site:

Avoid Internal Getters/Setters

In native languages like C++ it\'s common practice to use getters (e.g. i = get

7条回答
  •  借酒劲吻你
    2020-12-08 08:14

    Performance wise, there is no difference in accessing this.field or that.field.

    The feeling that an instance field is more accessible to the object hosting it is just a syntax illusion.

    OO wise, seriously, how complex can an Android app become? Many of the OO mantras are from building monster apps. What's the big deal if your little app uses objects like structs?

    And even in a huge app, as long as it's in house, and all source code accessing a field are available for refactoring, there is no problem at all exposing the fields.

提交回复
热议问题