|
|
|
good chemistry is complicated, and a little bit messy -LW |
|
| PerlMonks |
Re: the need to reblessby demerphq (Chancellor) |
| on Nov 21, 2005 at 10:20 UTC ( [id://510455]=note: print w/replies, xml ) | Need Help?? |
This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.
I have objects that are lazily evaluated using rebless. Basically the objects represent a pricing scheme. Until $obj->price() is called the objects are just a hash of the parameters required to run a query out of the DB to get the data and are of the class 'Pricer::Stub', when Price::Stub::price() is called the routine extracts the required data and converts itself into a real Pricer object. And then calls price() a second time on the new object. Code using the Pricer object never knows or cares which object type is involved, as the Pricer objects are manufactored by a factory object. I used this because the $obj->price() method is called very often, and thus I didnt want conditional logic in the price() method itself to handle this behaviour. Personally I think this is a very effective design pattern and I'm happy to use it.
--- $world=~s/war/peace/g
In Section
Meditations
|
|
||||||||||||||||||||||||