Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re^4: Tutorial: Introduction to Object-Oriented Programmingby adrianh (Chancellor) |
on Dec 13, 2002 at 08:32 UTC ( [id://219532]=note: print w/replies, xml ) | Need Help?? |
Another issue has just come to mind. With the object attributes being keyed on "$self", which includes the name of the class, you can no longer bless an object into a sibling class to implement state transitions. Again, I guess some people would consider this a feature. I quite like the technique myself :-) To overcome you'll need to strip out the class name. Assuming nobody changes the output format of references in later perl versions something like this should work.
Also, there is another advantage to Abigail-II's method. Storing the attributes in separate hashes should less expensive in memory - buckets cost less than hashes. Might make a difference if you're creating lots of objects.
In Section
Meditations
|
|