News Feed
Jobs Feed
Sections




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

Travis Swicegood's Blog:
Why Inheritance Sucks
October 12, 2007 @ 10:11:00

Travis Swicegood has made two blog posts about his agreement with other statements made about why class inheritance sucks.

From the original comments made by Bernard Sumption:

All of the pain caused by inheritance can be traced back to the fact that inheritance forces 'is-a' rather than 'has-a' relationships. If class R2Unit extends Droid, then a R2Unit is-a Droid. If class Jedi contains an instance variable of type Lightsabre, then a Jedi has-a Lightsabre.

Travis agrees and then comes back with his second post to clarify something - composition versus inheritance:

I approach OOP from a flexibility standpoint with one of its biggest flex-points being loose coupling which in turn promotes reusability. I'm going to use Event as a hypothetical example.

He uses Events and design pattern illustrations (like the Visitor and Observer) to help illustrate his point.

0 comments voice your opinion now!
inheritance designpattern observer event composition confusion inheritance designpattern observer event composition confusion


blog comments powered by Disqus

Similar Posts

Evolt.org: Quick Calendar Using AJAX and PHP

Matthew Weier O'Phinney: ZF2's New Controller::init()

Hasin Hayder's Blog: Using ActiveRecord Library Separately from CodeIgniter

PHPMaster.com: Implementing a Unit of Work - Handling Domain Objects through a Transactional Model

Matthew Weier O'Phinney's Blog: A Simple PHP Publish-Subscribe System


Community Events











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


overview install language opinion release composer unittest symfony2 code introduction example facebook security component application hhvm podcast package framework hack

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