
的确可以暴露,如果1. 所有内外代码都是你自己写;2. 这个模块再也不改了;3. 不会继承它,或者继承但不改变语义。
David John Wheeler有一句名言:
“All problems in computer science can be solved by another level of indirection.”
getter、setter就是个很好的中间层。
直接摘录stackoverflow上一个不错的总结:

的确可以暴露,如果1. 所有内外代码都是你自己写;2. 这个模块再也不改了;3. 不会继承它,或者继承但不改变语义。
David John Wheeler有一句名言:
“All problems in computer science can be solved by another level of indirection.”
getter、setter就是个很好的中间层。
直接摘录stackoverflow上一个不错的总结: