![]() |
|
good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
comment on |
( #3333=superdoc: print w/replies, xml ) | Need Help?? |
The section on Encapsulation in Chapter 15 of Damian's Perl Best Practices clearly illustrates the several advantages of inside out objects. While I have a sense of the advantages, I lack the knowledge/experience to even summarize them here. However, I suspect that the following twist on that version of inside-out objects still retains the advantages while being simpler (but do not know enough to know for sure).
Update: Regarding performance, my inclination is to put the spell-check subs (sub attribute() returning 'attribute') in a BEGIN block under the assumption that the compiler will optimize away these trivial subs. Update: Modified code to respond to comment by chromatic. Update - Psychological Aspect: I now understand why I had trouble using the original scheme in PBP. While using that scheme, my mind had to deal with multiple attributes -- there wasn't any single object for my mind to use. The Package name represents a family of potential objects; and the object itself doesn't provide anything to think about since it is just a meaningless un-named scalar; so my mind had to deal with the multitude of "attribute_of" (which overloaded the mind to the point of being almost paralyzing). In the present scheme, my mind works with a single, meaningful hash.
|
|