I don't understand what you mean by "higher up".
I mean the code to handle this is lifted outside the class and into the caller.
The code is almost identical to yours, just written directly in Perl, rather than some new and cumbersome operator application language.
I, for one, like the addition of small, domain specific languages. Your choice is to either learn an API or learn a (small) language. Choosing one or the other tends to force you twards different design decisions, but the cost of learning is not so different.
I also don't understand what you mean about "insufficient encapsulation".
Encapsulation is hiding data and behavior. Applying trvial mutators exposes data. It's therefore bad encapsulation. QED.
But again, I think dragonchild's giveRaise() and givePromotion() methods are better than my own implementation.
"There is no shame in being self-taught, only in not trying to learn in the first place." -- Atrus, Myst: The Book of D'ni.
In reply to Re^17: Assignable Subroutines
by hardburn
in thread Assignable Subroutines
by dragonchild
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |