Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^2: Your favorite objects NOT of the hashref phylum (array w/ consts)

by nothingmuch (Priest)
on Mar 26, 2006 at 08:27 UTC ( #539269=note: print w/ replies, xml ) Need Help??


in reply to Re: Your favorite objects NOT of the hashref phylum (array w/ consts)
in thread Your favorite objects NOT of the hashref phylum

How do you handle multiple inheritance?

Perhaps with the Moose module you can write a metaclass that uses named syntax for attributes, but compiles the offsets as late as possible in a way that takes care of MI, much like $any_static_language's vtables are compiled.

-nuffin
zz zZ Z Z #!perl


Comment on Re^2: Your favorite objects NOT of the hashref phylum (array w/ consts)
Re^3: Your favorite objects NOT of the hashref phylum (inherit)
by tye (Cardinal) on Mar 27, 2006 at 08:02 UTC

    I strongly dislike class-making frameworks that everyone and their dog wants to bolt onto the side of Perl. So I'm not going to be writing any plug-ins for one. I've never seen any significant value in any of them and most of them look quite prone to break things due to ETOOMUCHMAGIC (and I've seen several actually break things), so I'm quite happy to avoid all of them completely. I don't find it particularly challenging to implement reasonable classes using just Perl 5 and I like that understanding my code doesn't require understanding some extra framework first.

    I try to (and succeed at) avoiding inheritance in most cases, especially in Perl. Inheriting interfaces (aka pure-virtual classes) is a fine thing. Inheriting from a class that contains code is very often not the best solution and I (and many other experienced developers) know all too well how inheritance binds very tightly and can lead to brittle designs that become a burden.

    So, if Perl had interfaces I might write Perl classes that inherit from more than one set of interfaces. Since Perl doesn't have (non-trivial) interfaces, I only rarely use inheritance in Perl and I have never been tempted to use multiple inheritance in Perl.

    If I had new-fangled near-inheritance tools (traits, mix-ins, or whatever you want to call them), I'd probably make use of those more often.

    I find that I'm more successful in the long run when I bend my approach to a problem to fit the language that I'm solving it in, rather than trying to bend the language to fit my first choice of approach. So I write Perl 5 classes in Perl 5 OO and easily resist the urge to try to turn Perl into my ideal OO framework, even though Perl often appears to make it somewhat easy for you to bend it.

    - tye        

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://539269]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2014-12-29 14:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (189 votes), past polls