close

In general having getters and setters is showing poor abstraction, don't do it. 

Getters and setters provide an illusion of encapsulation,

it will expose private state of an object using public accessors.

將data member 設為private , 主要就是想要隱藏他 , 但如果又用

getter or setter 來對他進行存取 , 這就違反了當初想要封裝他的意義.

so , it is really poor abstraction.


ref : http://www.adam-bien.com/roller/abien/entry/summary_public_getters_and_setters

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 JerryCheng 的頭像
    JerryCheng

    KwCheng's blog

    JerryCheng 發表在 痞客邦 留言(0) 人氣()