Are trivial protected getters blatant overkill?
Posted
by
Panzercrisis
on Programmers
See other posts from Programmers
or by Panzercrisis
Published on 2013-10-24T12:57:30Z
Indexed on
2013/10/24
16:08 UTC
Read the original article
Hit count: 255
Something I really have not thought about before (AS3 syntax):
private var m_obj:Object;
protected function get obj():Object
{
return m_obj;
}
private var m_str:String;
protected function get str():String
{
return m_str;
}
At least subclasses won't be able to set m_obj or m_str (though they could still modify m_obj). Is this just blatant overkill?
I am not talking about doing this as opposed to making them public. I am talking about doing this instead of just making the variables themselves protected. Like this:
protected var m_obj:Object; //more accessible than a private variable with a protected getter
protected var m_str:String; //more accessible than a private variable with a protected getter
© Programmers or respective owner