Best to use Private methods or Protected methods?

后端 未结 10 2314
[愿得一人]
[愿得一人] 2020-12-03 09:52

In a lot of my PHP projects, I end up with classes that have non-public functions that I don\'t intend to extend.

Is it best to declare these as protected, or privat

10条回答
  •  暖寄归人
    2020-12-03 10:24

    I think you should only expose what you need to when you need to. This makes doing impact assessments of changes easier. i.e. If a method is private, you know the impact will be minimal if you change it.

提交回复
热议问题