Assuming that we have the following class, is it better (in terms of oop) to pass the object of class Foo
to Bar
constructor rather than pass only the arguments baz
and qux
to Bar
constructor?
class Foo
{
public $baz, $qux;
public function __construct($baz, $qux)
{
$this->baz = $baz;
$this->qux = $qux;
}
public function main()
{
$bar = new Bar($this);
//OR
$bar = new Bar($this->baz, $this->qux);
}
}
Aucun commentaire:
Enregistrer un commentaire