Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Strategy Handles

by simon.proctor (Vicar)
on Jan 04, 2006 at 13:42 UTC ( [id://520896]=note: print w/replies, xml ) Need Help??


in reply to Strategy Handles

Surely changing inheritence on the fly is against the idea of the OO patterns in the first place? If you need to change what output you provide by dynamically changing inheritence then I don't see how you can say this alternate technique is OO based. I would be interested in seeing arguments to say that it is.

I have my own arguments against this:

By changing the inheritence dynamically (assuming, of course, that it were possible in any language) you are replicating the same process as interfaces (well sort of). So why muck with the chain (which can have interesting side effects) when the principle of the strategy pattern is to load objects capable of completing the responsibilities of the task via the interface required. The contract is between the calling code and the interface and you assume that it will do what you want. By working on the problem via changing inheritence you are circumnavigating that contract. Ok if you are a sole programmer. Not ok if you are working in a team (or across companies). Its certainly frought with problems.

If this were available I think I would be pretty safe in saying that I would never make use of it.

But that is my 2p. Please take with a pinch of salt :)

S

Replies are listed 'Best First'.
Re^2: Strategy Handles
by jdporter (Chancellor) on Jan 04, 2006 at 19:50 UTC
    If you need to change what output you provide by dynamically changing inheritence then I don't see how you can say this alternate technique is OO based.

    I'm not into making rigorous definitions of OO, nor am I arguing that this technique is or isn't OO in any kind of purist sense. But considering that it is all about inheritance of methods, I don't know what other drawer to file it under. Remember that Perl's OO is not (much) like any other language's OO. One of the ways in which it's different comes from the highly dynamic nature of the language itself. And this technique is merely an example of that.

    If this were available I think I would be pretty safe in saying that I would never make use of it.

    It is available. And no, I don't actually expect anyone to make use of it. :-)

    We're building the house of the future together.
      > But the fact that it is all about inheritance of methods,

      Yeah thats true but it is quite evil. And in a monestary too ;).

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2024-03-19 03:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found