Hi, i have made a set of perl modules and CGIs for creating online exercises (multiple choice, etc). It's called OEME and its hosted on CodigoLivre (
http://www.codigolivre.org.br/projects/oeme), if you fell like taking a look at it.
Well, the thing is, I created a superclass Question, and subclasses to it to actually be each kind of question. Question has the normal acessor functions, that are used in all Question::* classes.
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
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.