There's more than one way to do things | |
PerlMonks |
Problems and pitfalls with reblessing?by Dallaylaen (Chaplain) |
on Nov 22, 2018 at 07:46 UTC ( [id://1226164]=perlquestion: print w/replies, xml ) | Need Help?? |
Dallaylaen has asked for the wisdom of the Perl Monks concerning the following question: Hello esteemed monks, Say I have an object that has a construction phase that ends via a finalize() method. After that, no more modifications may be made. Currently it is implemented via a lock within the object. However, I'm tempted to do a bless $self, "My::Module::Readonly"; and remove mutators from that class (or make them dying stubs). This looks simple and efficient, but blessing an object into another package smells like a hack and/or abuse of Perl object system. What are the possible problems/pitfalls with such approach? One thing that comes to mind is extending the initial class. Are there more?
Back to
Seekers of Perl Wisdom
|
|