Since Perl's implementation of OO is commonly used with a hash, one hash for a class and all it's 'parents'. To avoid collision between names of inherited attributes a namespace is defined for each package and prepended to the attributes of an object. This is a poor summary of section 6.2.6 of OO Perl by Damian Donway.
Well it set me to thinking, that since I was brought up believing all properties of an object should be viewed through accessor methods, and altered through mutator methods, one way of achieving this was to slap on a long namespace to stop people tampering, it seemed a little more dictatorial than the '_' affordance, although I stuck to that too.
$object->{_id}; $object->{_private_property_of_template_called_id_leave_it_be}; # Both could then have an accessor method, respectively sub get_id () { $_[0]->{_id} } sub get_id () { $_[0]->{ _private_property_of_template_called_id_leave +_it_be } } # And each would be called $object->get_id();
Obviously, I hope, you can see that I've exagerated the length of the property, but does this makes sense to use? I really am in two minds as to whether this is a good thing, so I thought I'd post it here as people have some pretty strong views on OO...
--
Brother Frankus.
¤
In reply to A new take on affordance. by frankus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |