|
From: Nick S. <ni...@te...> - 2003-01-13 09:14:18
|
hi all! i'm thinking of providing a "plug-in" mechanism so that programmers can extend an existing SPOPS object with additional properties and even new functionality (methods). i use the setup found in the SPOPS/eg dir which is of course chris' idea: - have one class per object - the class has at least two methods which are - _base_config(): returns the SPOPS config hash - config_class(): calls SPOPS::Initialize->process() with the config hash from _base_config() my idea is to write a new sub-class of the respective object. the constructor of the new object will call the "_base_config" method from its parent and extend the returned array as necessary, eg with more "has_a" fields. there are a few problems with this technique: if an object has "has_a" properties (which are again classes), the config_class() methods of these classes have to be called *before* the respective class calls SPOPS::Initialize->process(), because the "has_a" classes must be "known" by the SPOPS subsystem (which means, they must have been created by SPOPS before). one solution is of course calling the config_class() method of all "has_a" classes *in* the SPOPS::Initialize->process() call of the respective class. this is the way chris goes in the example code. this may result in multiple config_class() calls of a single class. has anyone another solution for this? what do you think about this "inheritance" technique? is this text understandable at all? cheers, nick __________________________________________ nick sutterer cb&h productions ni...@te... the computer helps us solving problems which we wouldn't have without it. |