Re: PDO: extend or encapsulate?

From: Date: Sun, 15 Jul 2012 10:50:06 +0000
Subject: Re: PDO: extend or encapsulate?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-318481@lists.php.net to get a copy of this message
From OOP point of view. Use encapsulation: When a class has a "has-a" relation-ship with other class you should use encapsulation. For example, If MyDB is a class that "has-a" pdo driver in it, then PDO will be encapsulated inside MyDB class. This is also called containment. MyDB should contain PDO. Use inheritance: When a class has a "is-a" relation ship with other class use inheritance. For example, Dog is an Animal. so Dog should extend Animal class. MyPHPDb is-a PHP Database Object (aka PDO). So it'll be inheritance. MyPHPDb should extend PDO. Think about the relation have. Then implement it. -- Shiplu.Mokadd.im ImgSign.com | A dynamic signature machine Innovation distinguishes between follower and leader

« previous php.general (#318481) next »