pauloschreiner has asked for the wisdom of the Perl Monks concerning the following question:
Each question is set on a PostgreSQL database, each type on a differente table. Each id can be gotten with the following SQL command SELECT NEXTVAL('tablename_id'). That works for all subclasses. So I defined a constant in each subclass, called table, that contains the name of the table, and a _get_new_id function in the Question superclass, that does the select according to the table name of $self, wich will, off course, call the table function(constant) of the subclass.
Now, everything I ever read about OO (even in the moral liberal perl world) says one should never let superclass acess subclass data. So I ask, is this technique I describe actually superclass acessing subclass data? And if so, is it justifiable to do it? And is there another, more correct in the OO sense, way to do it?
Thanks in advance,
Paulo Schreiner
Edit by tye
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Superclass acessing sublass data
by adrianh (Chancellor) on Dec 19, 2002 at 13:20 UTC | |
|
Re: Superclass acessing sublass data
by djantzen (Priest) on Dec 19, 2002 at 17:32 UTC |