Page 1 of 1

Creating new subclasses from User Input?

Posted: Wed Mar 10, 2004 3:46 am
by llanitedave
I’m still in the early stages of learning PHP and object-oriented programming, and I’ve got a plethora of questions.

This one’s a bit theoretical -- I wanted to get some ideas on client-created classes in a PHP application.

I’m developing a tracking database for scientific samples. The user of the database will be defining what kinds of samples and attributes they want to track. For instance, a water sample might be measured in volume, a soil sample by mass, a chemical covering by surface area. The attributes for the sample types would be assigned by the user.
I have designed a “samples” class to hold the data that all sample objects would have in common: ID number, date created, storage location, etc.

Are there any good techniques for automatically creating subclasses from user-defined attributes? I can envision a sample class extended by such subclasses as “soil”, “water”, and “film”, or an infinite number of others. Does anyone know of resources that might give me some direction here?

Thanks!