in reply to (Ovid) Re(3): A question of Inheritance
in thread A question of Inheritance

First off, I don't see that Perl has any "limitations" when it comes to OO. I've been able to simulate every single OO feature I've ever wanted to have. You just have to be willing to either trust someone else's implentation (which is what you do for all other OO languages) or (what I do) roll your own.

First off, I've never used any package to do OO work. I've never even looked at any code (other than Advanced Perl, and it didn't even work out of the box).

What I do for data inheritance (both class and instance) is to have a virtual base class that does all that book-keeping for you. I've used $self->SUPER::new to do that, but I prefer the virtual base class.

As for method inheritance - isn't that what @ISA provides for you? Well, more of method re-dispatch, but isn't that the same thing?

As for class vs. inheritance methods ... If you have a huge amount of class methods vs. a small amount of instance methods, doesn't that mean you have a singleton? If you have a huge amount of instance methods and a small amount of class methods, doesn't that mean you're working with a set of objects that have a few book-keeping functions in the background? *shrugs*

I guess I just don't see things as black and white and many others do. I write stuff. It gets the job done. I have fun doing it. I get paid. I go home to my fiancee and kids. :-)

------
We are the carpenters and bricklayers of the Information Age.

Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

Replies are listed 'Best First'.
Re: Re: (Ovid) Re(3): A question of Inheritance
by herveus (Prior) on Dec 12, 2001 at 09:24 UTC
    Howdy!

    I've been wrestling once again with another pet project. I have inherited a C library that I want to implement in Perl. The data being handled seems to have a strong inclination toward OO-ness. Since I have been getting familiar with Design Patterns (Gamma, et al), I have been trying to identify uses for the patterns in my scheme.

    One element is a "Category". These come in two flavors - "CatalogCategory" (permanent) and "ScratchCategory" (ephemeral). I have a bunch of methods that would be class methods in Category along with a number of object methods. I have come up with a "Categories" class which will be a singleton and contain a factory method that will provide "Category" objects as needed. Since I have other types of elements that behave similarly, I have cobbled together a Class::FlyweightFactory module to simplify setting the factories up...

    yours,
    Michael