pharo-contributions / MethodProxies

A library to decorate and control method execution.
6 stars 7 forks source link

Illustrating handlers sharing problem and proposing a solution #2

Closed StevenCostiou closed 1 year ago

StevenCostiou commented 2 years ago

The solution includes a simple container class in handlers, intended to share a common object named "model". That model implements common behavior and shares data to be used upon a proxified method execution.

Naming and implementation are maybe wrong, I'm trying to illustrate my usecase simply and quickly.

guillep commented 2 years ago

Yes I think you're right. I also think that by default handlers should not know the proxy. Moreover, the instance variable is not used in any but one subclass. Thus it's probably better that we remove that setter + inst var.

I propose that if some handler would like to have a reference to the proxy then:

That could be part of a handler subclass available to users. I don't know what name could be put in there. MpSingleProxyHandler?

guillep commented 2 years ago

It's even worse. The only usage, MpProfilingHandler, is buggy. It's usage of the proxy instance variable is wrong, it needs the proxified method instead.

guillep commented 1 year ago

I think that not having a reference from the proxy to the handler (as in https://github.com/pharo-contributions/MethodProxies/pull/3) solves already this issue.

Let's see how it goes and reopen this one if needed.