Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:33282 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 97893 invoked by uid 1010); 19 Nov 2007 06:03:07 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 97878 invoked from network); 19 Nov 2007 06:03:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Nov 2007 06:03:07 -0000 Authentication-Results: pb1.pair.com smtp.mail=larry@garfieldtech.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=larry@garfieldtech.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain garfieldtech.com from 76.96.30.40 cause and error) X-PHP-List-Original-Sender: larry@garfieldtech.com X-Host-Fingerprint: 76.96.30.40 qmta04.emeryville.ca.mail.comcast.net Received: from [76.96.30.40] ([76.96.30.40:50890] helo=QMTA04.emeryville.ca.mail.comcast.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 55/4D-31009-91721474 for ; Mon, 19 Nov 2007 01:03:05 -0500 Received: from OMTA07.emeryville.ca.mail.comcast.net ([76.96.30.59]) by QMTA04.emeryville.ca.mail.comcast.net with comcast id EVvi1Y0091GXsuc0A00H00; Mon, 19 Nov 2007 06:03:06 +0000 Received: from earth.ufp ([71.228.13.89]) by OMTA07.emeryville.ca.mail.comcast.net with comcast id EW341Y00A1vH2xB0800000; Mon, 19 Nov 2007 06:03:05 +0000 X-Authority-Analysis: v=1.0 c=1 a=8pif782wAAAA:8 a=UoIjxXftR-nbb143NqAA:9 a=pNh4AdKMfSAEhU310PIA:7 a=PiRI2SIEavLlYZeR5GAS90TDz4QA:4 a=FHBbIDN7CdwA:10 a=JqzK7hVu6n4A:10 Received: from localhost (localhost [127.0.0.1]) by earth.ufp (Postfix) with ESMTP id 774F3D8314 for ; Mon, 19 Nov 2007 00:03:01 -0600 (CST) Received: from earth.ufp ([127.0.0.1]) by localhost (earth.ufp [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id f+eITvMgqKhY for ; Mon, 19 Nov 2007 00:03:01 -0600 (CST) Received: from vulcan.ufp (vulcan.ufp [192.168.42.4]) by earth.ufp (Postfix) with ESMTP id 555AED8308 for ; Mon, 19 Nov 2007 00:02:51 -0600 (CST) To: internals@lists.php.net Date: Mon, 19 Nov 2007 00:03:40 -0600 User-Agent: KMail/1.9.6 (enterprise 0.20070907.709405) References: <1195140437.23612.5.camel@sbarrow-desktop> <1195450232.12342.25.camel@sams-room> In-Reply-To: <1195450232.12342.25.camel@sams-room> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-ID: <200711190003.40228.larry@garfieldtech.com> Subject: Re: [PHP-DEV] Multiple class inheritance From: larry@garfieldtech.com (Larry Garfield) It sounds like you want to be using decorators instead. http://en.wikipedia.org/wiki/Decorator_pattern On Sunday 18 November 2007, Sam Barrow wrote: > What is the general opinion on multiple class inheritance. I have a need > for it. I have objects for all user input fields. > > $username = new field ; > $username -> name = 'username' ; > $username -> maxLen = 32 ; > > I have three types of fields. Fields that are automatically put in the > database, such as timestamps, fields that are inputted but not stored, > such as "confirm password", and fields that are inputted by the user AND > stored in the database, such as username and password. > > Now i have 3 classes: > > - abstractField (has methods and properties that apply to all fields). > - inputField, extends abstractField (has methods and properties for > display of input form elements and labels). > - dbField, extends abstractField (has methods for storing and retrieving > in db, etc.). > > However for fields that are inputted AND stored in the db, i need to > extend both inputField and dbField. > > - inputDbField extends inputField, dbField. > > Sure, there may be quick hacks to do this, but the only proper way seems > to be to extend both classes, and I don't want to duplicate any code > (dbField and inputField are both pretty big, and any modifications will > also have to be replicated). > > And no, I don't want to use interfaces. Interfaces will barely do > anything for me, I'll still have to duplicate my method bodies, and > properties. -- Larry Garfield AIM: LOLG42 larry@garfieldtech.com ICQ: 6817012 "If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it." -- Thomas Jefferson