Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: changing moose object classes on the go

by moritz (Cardinal)
on Mar 19, 2013 at 18:40 UTC ( #1024356=note: print w/ replies, xml ) Need Help??


in reply to changing moose object classes on the go

If I simply bless my $dog into LABRADOR then he won't be golden. How can I resolve this situation?

By creating a new LABRADOR object, and using it instead of the old object. You can reuse the attributes from the original DOG object.

Seriously, changing the type of an object is a an usual requirement, and might point to a flaw in your overall design. If a dog is a labrador, it's already born a labrador. Or phrased differently, time-dependent properties should not encoded in the type.


Comment on Re: changing moose object classes on the go

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (20)
As of 2015-07-31 16:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (279 votes), past polls