Extending a class or not

From: Date: Mon, 20 Jan 2003 10:17:15 +0000
Subject: Extending a class or not
References: 1 2 3  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-12614@lists.php.net to get a copy of this message
Hi all, Say I want to write a new class that creates a calendar in which every day can have one or more events attached to it. e.g: --------------- March 21 - go to docter - finish report ---------------- I found two classes that are helpful: HTML_Table and Date_Calc. I don't know if I should extend a class or write some sort of wrapper class. I can do something like: class EventCalendar extends HTML_Table { EventCalendar($args); HTML_Table::HTML_Table($args); insertEvent() { this->setCellContents($args) ... } } or I can do something like: class EventCalendar { var $_table; EventCalendar($args) { $this->_table = new HTML_Table($args); } insertEvent() { this->_table->setCellContents($args) ... } } I guess one advantage of the 1st example is that you can override certain methods, but other than that I wouldn't really know which option to chose. Does anyone have guidelines / recommendations for this? Thanks. Jeroen

« previous php.pear.dev (#12614) next »