Hello all,

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:

class Foo
{
  protected $bar;

  public function getBar()
  {
    return $this->bar;
  }

  public function setBar( $baz )
  {
    $this->bar = $baz;
  }

  // ...

  protected function doSomething()
  {
    $new_value = $this->getNewValue();

    $this->bar = $new_value;

    // OR

    $this->setBar( $new_value );
  }
}

Which is preferred, if either?

Thanks!

--
Yitzchak Schaffer
Systems Manager
Touro College Libraries
33 West 23rd Street
New York, NY 10010
Tel (212) 463-0400 x5230
Fax (212) 627-3197
Email yitzchak.schaf...@tourolib.org

Access Problems? Contact systems.libr...@touro.edu
_______________________________________________
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