in reply to Re: Where/When is OO useful?
in thread Where/When is OO useful?
Many OO CPAN modules are simplicity themselves to use and modify.
I don't agree. I think many OO modules are hard to modify - the latter meaning "subclass".
Here's coding problem.
Someone has written a BaseballPlayer class, to maintain statistics of players. Your task is to subclass it to create a BaseballPlayer::Pitcher class so the additional statistics for pitchers can be dealt with.Where are you going to store your instance data?
If you answer "in the hash returned by the constructor of the BaseballPlayer class", or "in whatever object the superclass uses", or "that depends on how the BaseballPlayer class is implemented", you fail the test. And why do you fail? Because you are breaking the basic concept of object orientness: encapsulation. It shouldn't matter how the superclass is implemented. Unfortunally, Perl doesn't make it easy to use inheritance. It all works handy-dandy if you can enforce a certain style, implementation or module usage of the total inheritance tree, but that isn't usually the case. It wouldn't be code reuse if you had to write everything yourself, now would it?
Abigail
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Where/When is OO useful?
by Petruchio (Vicar) on Jun 25, 2002 at 04:00 UTC | |
by Abigail-II (Bishop) on Jul 01, 2002 at 11:43 UTC | |
by sauoq (Abbot) on Sep 10, 2002 at 19:42 UTC | |
by Anonymous Monk on Aug 28, 2002 at 03:16 UTC | |
by Abigail-II (Bishop) on Aug 28, 2002 at 07:53 UTC | |
by scrottie (Scribe) on Jun 14, 2003 at 09:25 UTC | |
Re: Re: Where/When is OO useful?
by erikharrison (Deacon) on Jun 21, 2002 at 23:30 UTC |