News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

PHPMaster.com:
Reusing Implementation - a Walk-through of Inheritance, Composition, and Delegation
July 16, 2012 @ 11:42:54

On PHPMaster.com today there's a new tutorial posted that wants to provide a guide to walk you through a trio of ideas to help with code/idea reuse in your applications - inheritance, composition and delegation.

The popular belief is that reusing implementation, thus producing DRYer code, boils down to exploiting the benefits that Inheritance provides, right? Well, I wish it was that easy! [...] If you don't know what path to travel when it comes to reusing implementation, in this article I'll be doing a humble walk-through on the Inheritance/Composition/Delegation trio in an attempt to showcase, side by side, some of their most appealing virtues and clunky drawbacks.

He starts off with a look at Inheritance, showing with a small code sample showing the creation of an interface and a resulting PDO adapter class implementing it. He also shows the concept of composition, following the ideas of the Adapter pattern. In his Delegation example he shows how to implement the creation of the connection object as a part of the class' creation.

0 comments voice your opinion now!
inheritance delegation composition reuse implement tutorial


blog comments powered by Disqus

Similar Posts

Liip Blog: Table Inheritance with Doctrine

OpenShift Blog: Integrate PHPStorm and SFTP into OpenShift

Content with Style: Linkedin and Zend_Oauth

Inviqa techPortal: Create a RESTful API with Apigility

Fabien Potencier's Blog: Create your own framework... on top of the Symfony2 Components (part 6)


Community Events





Don't see your event here?
Let us know!


community podcast introduction laravel release list zendserver tips api symfony threedevsandamaybe language code framework development developer interview conference deployment series

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework