in reply to Programming patterns

If your Trained::Monkey object gets passed a Widget object, and is expected to do something with the Widget object, but only if the Widget object is in the correct state; then it should be the Widget object which makes the decision about whether it's in the right state, not the Trained::Monkey object.

Why? Because you may eventually subclass Widget to create a Widget::Complicated where the assessment of its state isn't as simple. You want to avoid having to give your monkey extra training.

perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'