prowler has asked for the wisdom of the Perl Monks concerning the following question:
Hello,
I have a bunch of modules such as Teacher, Student and Subject that crossreference each other: Teacher has ->get_subjects(), ->get_subject_at($time) etc. but Student has no direct link to Teacher.
I need to subclass one of these classes to provide extra functionality (in a deployment for a university, Lecturer (is a Teacher) has ->get_research projects() as well, but the other classes haven't changed.)
The problem: If the other classes haven't changed then when
is called (with $some_subject being a Subject) $lecturer is in fact, not a Lecturer.$lecturer = $some_subject->get_teacher();
Obviously I can subclass Student and Subject to Uni_Student and Uni_Subject and overwrite all the cross referencing code to behave as desired:
returns an array of Uni_Subjects. However this can involve quite a lot of modification just to enable a change to a single class; the dependencies have to be traced all the way back.@subjects = $some_uni_student->get_subjects();
Is there a better way?
Thanks,
Prowler
- Spelling is a demanding task that requies you full attention.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Inheritance and module cross dependencies
by gaal (Parson) on Jan 10, 2005 at 06:59 UTC | |
by prowler (Friar) on Jan 10, 2005 at 07:29 UTC | |
by gaal (Parson) on Jan 10, 2005 at 07:42 UTC | |
|
Re: Inheritance and module cross dependencies
by NetWallah (Canon) on Jan 10, 2005 at 05:19 UTC | |
by Anonymous Monk on Jan 10, 2005 at 07:31 UTC | |
by prowler (Friar) on Jan 10, 2005 at 05:39 UTC |