Calling the variable property directly vs getter/setters - OOP Design

后端 未结 7 820
-上瘾入骨i
-上瘾入骨i 2021-01-17 09:31

I know this is probably subjective but I read this optimization page from Google for PHP and they suggest use the variable property directly without the need of getters and

7条回答
  •  遥遥无期
    2021-01-17 10:15

    A boilerplate answer, I'm afraid but I would suggest the following: If you have no encapsulation problems for your class (enforcing business logic, etc.) by exposing this property to other users, it is perfectly ok to do so.

提交回复
热议问题