On Jan 12, 2010, at 11:58 AM, Yitzchak Schaffer wrote:
> What's BP for changing the values of protected properties within a class that 
> also has public getter/setters?  e.g. in Foo::doSomething() below:
...
>  protected function doSomething()
>  {
>    $new_value = $this->getNewValue();
> 
>    $this->bar = $new_value;
> 
>    // OR
> 
>    $this->setBar( $new_value );
>  }
> }

If you go through the effort to create getter/setter methods, you should always 
use them.  Otherwise, you lose the benefit of having them - which is that more 
logic can easily be placed in the getter and setter methods to do something 
more than simply assign/retrieve the variable.

-Rob

_______________________________________________
New York PHP Users Group Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

http://www.nyphp.org/Show-Participation

Reply via email to