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
[EMAIL PROTECTED]               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

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to