☞ | ![]() ![]() |
28 |
This raises several new potential problems
What should the name of the hash key be?
The name of the hash key should be Class::Observable::something
Say, Class::Observable::_observers
We will provide an escape hatch in case this choice ever poses a problem
The name will not be hardcoded in our module
Instead of:
push @{$self->{Class::Observable::_observers}}, ...;
We will always have:
push @{$self->{$self->key}}, ...;
sub key { "Class::Observable::_observers" }
Now if the key choice is bad for someone, they can change it
Just subclass Class::Observable and override key
It only takes a moment
☞ | ![]() |
☞ |