Ovid has asked for the wisdom of the Perl Monks concerning the following question:
B has similar functionality to A. A returns some data, B writes the data to a file, but in a different format than the data returned from A. Under some circumstances, the data written to the file from B is in the exact same format as the data returned from A.[base] / \ / \ [subclass A] [subclass B]
However, I don't want B to inherit A's methods as I don't want the user accessing them from the object. In other words, I might have
What I don't want ismy $object = A->new; $object->someWeirdMethod;
But that happens if I inherit from A, unless I write a bunch of methods to trap those calls and let the user know they shouldn't do that.my $object = B->new; $object->someWeirdMethod;
The alternative seems to be having B instantiate an A object, but having subclasses instatiating instances of each other strikes me as problematic. I keep up that habit and I might start winding up with circular references that I'll have to explicitly destroy.
Summary: two options that I see:
Cheers,
Ovid
Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: OO-style question
by merlyn (Sage) on Dec 30, 2000 at 00:46 UTC | |
Re: OO-style question
by Adam (Vicar) on Dec 30, 2000 at 01:35 UTC | |
by coreolyn (Parson) on Dec 30, 2000 at 03:13 UTC | |
by merlyn (Sage) on Dec 30, 2000 at 09:03 UTC | |
by coreolyn (Parson) on Dec 30, 2000 at 19:45 UTC | |
by Fastolfe (Vicar) on Dec 30, 2000 at 19:53 UTC | |
| |
by Adam (Vicar) on Dec 31, 2000 at 07:42 UTC | |
by tilly (Archbishop) on Dec 31, 2000 at 08:45 UTC | |
| |
by btrott (Parson) on Dec 31, 2000 at 08:04 UTC | |
by tye (Sage) on Dec 31, 2000 at 11:01 UTC | |
Re: OO-style question
by footpad (Abbot) on Dec 30, 2000 at 09:27 UTC | |
(tye)Re: OO-style question
by tye (Sage) on Dec 30, 2000 at 00:58 UTC | |
Re: OO-style question
by coreolyn (Parson) on Dec 30, 2000 at 02:39 UTC |