vendredi 20 janvier 2017

Difference between aggregation and dependency injection

I have recently studied dependency injection design pattern .

class User
{

private $db;

public function __construct(Database $db) 
{
        $this->$db = $db;
}

}

I can not help but wonder that is the same thing that i learned in aggregation. Please do correct me if I am wrong . I know goals of dependency injection and aggregation are different . Is there anything that I am missing ?

Aucun commentaire:

Enregistrer un commentaire