Re: PDO: extend or encapsulate?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>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

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux