Problems? Is your data what you think it is? | |
PerlMonks |
Re: Re: Re: Re: Overloading inherited class methodsby Ovid (Cardinal) |
on Dec 04, 2002 at 19:11 UTC ( [id://217563]=note: print w/replies, xml ) | Need Help?? |
It was a problem here, but it may not have been completely obvious because I decided not to post the entire code of the superclass. However, the problem lies in issues like this: my ($class, %args) = @_;If that occurs, I might append extra data to %args that does not logically belong there in all cases. However, if I convert %args to a reference, I can keep my "extra" info seperate and I don't have to build as many special cases in my code to account for the extra hash keys: my ($class, $args, $id) = @_;(That's just an example, but you get the idea.) My problem lay in the fact that the subclassed constructor was expecting a single scalar id, which, if I passed the %args has from the get_list method, then the first element gets assigned to $id. Now, on second thought, I can see an error I made. I don't need to pass %args because the constructor already knows about it. Hmm... more work to do. Should take another two minutes :) Update: Took me less than two minutes, actually. Now my methods in the subclass look like this:
I am wondering now what would happen if I moved those into the superclass and exported them into subclasses (would that work? Then I wouldn't need to keep rewriting those methods for every class. I would just need to provide the %ARGS hash for configuration information and most objects would then simply use the superclass and have most of their methods just work. Interesting thought. Cheers, New address of my CGI Course.
In Section
Seekers of Perl Wisdom
|
|