[Ann] New version of Ghost

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
26 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Re: [Ann] New version of Ghost

Denis Kudriashov

2016-03-25 14:54 GMT+01:00 Denis Kudriashov <[hidden email]>:

Sorry to bother you but names are really important.

Exactly!!! 

Forgot to say. When I see words in class names like  Abstract, Handler, Delegator... I remember many "good" years with java. Please lets make names better. 
Reply | Threaded
Open this post in threaded view
|

Re: [Ann] New version of Ghost

demarey
In reply to this post by Denis Kudriashov

Le 25 mars 2016 à 14:54, Denis Kudriashov <[hidden email]> a écrit :

Hi

2016-03-25 9:47 GMT+01:00 Christophe Demarey <[hidden email]>:
  • Abstract proxy classes uses Ghost name instead of Proxy: there are GHObjectGhost and GHClassGhost.
  • GHProxyHandler renamed to GHGhostBehaviour. Concrete ghosts should implement #ghostBehaviour instead of #proxyHandler.
Why did you rename these classes?
I find the new names obscure and they do not provide a clue of what is the purpose of the class. Old names were clear and easily understandable.

Nice you ask. It can raise interesting discussion.

In previous version we have three classes to support basic object proxy:
GHInterceptionDelegator
GHProxyTrap 
GHAbstractProxy 
And now due to DNU approach it just one:
GHObjectGhost

And I guess you would call it GHObjectProxy or GHAbstractProxy. Lets look at wikipedia:
 
proxy, in its most general form, is a class functioning as an interface to something else. The proxy could interface to anything: a network connection, a large object in memory, a file, or some other resource that is expensive or impossible to duplicate. In short, a proxy is a wrapper or agent object that is being called by the client to access the real serving object behind the scenes 
 
So proxy is supposed to substitute some other object. But in many cases we not have other object. In many cases we construct special kind of objects which perform messages in not smalltalk way. For example imaging that we want to implement javascript prototypes (there was related post https://clementbera.wordpress.com/2016/02/17/mind-twister-toying-with-object-kernels). Prototype is definitely not kind of proxy. Or think about Mock object. It is not proxy too.
So generally Ghost is not about proxies. It is exactly about supernatural objects. With Ghost we construct special objects which behave in not natural smalltalk way. 

so is most magic than surnatural ;)

And in that perspective classic proxy is most primitive example of it. It just delegates all messages to another object (with little bit of logic).

Maybe you would suggest another name: GHInterceptionDelegator (what the name for GHGhostClass in that case?). 
But why we not call Object same way too (InterceptionDelegator)? Natural smalltalk objects just delegate message processing to methods from class methodDictionary (which is hidden by VM). 

So for me ObjectGhost reflects perfectly real intention of it. It is base class to construct unnatural smalltalk objects. And ClassGhost is unnatural object which can play role of natural object classes.

Now lets look at ProxyHandler vs GhostBehaviour. ProxyHandler play role of Behavior (Class) but for proxies. It defines how proxies will handle messages. But why we not call smalltalk Behaviour as ObjectHandler?
I hope now you see logic behind my names and ghost metaphor. Ghost models special objects with similar terms from natural objects: Object -> ObjectGhost and Behavior -> GhostBehaviour.

Thanks for the answer.
I now see more the rationale behind your naming but it is not obvious at a first sight.
If not there, please explain it in documentation, comments.

I changed title of Ghost project to: 
Ghost is framework to implement unnatural smalltalk objects like proxies and prototypes.,
  • New kind of proxies:
    • GHObjectVirus. It is special kind of GHClassProxy. It infects real object to intercept it messages. From meta level infected object looks like healthy object which means that meta messages are executed by infected object itself. As class virus looks like real victim 
Same remark here. The name is fun but it does not give any clue on the purpose of the class. Why not use GHMessageInterceptor?

And following such approach we will have GHInterceptionDelegator (for objects) and GHMessageInterceptor (for classes). Is it good?
I will describe virus more detailed soon. But maybe you remember there was very old advice from famous books: don't create classes which ends with -ER or -OR. (I not found original source but google shows many followers 

you have it in ‘Smalltalk best practices’ for sure

Thanks for the detailed answer Denis,
Christophe
Reply | Threaded
Open this post in threaded view
|

Re: [Ann] New version of Ghost

Denis Kudriashov
In reply to this post by Mariano Martinez Peck

2016-03-25 1:34 GMT+01:00 Mariano Martinez Peck <[hidden email]>:
Good example where I use viruses is stubbing real objects in Mocketry. I will announce it soon. You can do this:
rect := 0@0 corner: 2@3
rect stub area willReturn: 1000.

rect area "=> 1000".
rect origin "=> 0@0".


OK..I should take a look to the code...but...it looks to me that stub the only thing it does is to create the proxy and then the #become: ??

No. Stub should intercept all self-sends. Classic proxy can't do this.
Better example to show self-send stubbing:

rect := 0@0 corner: 2@3
rect stub width willReturn: 1000.

rect area "=> 3000"

(area is width and height multiplication).
Reply | Threaded
Open this post in threaded view
|

Re: [Ann] New version of Ghost

Denis Kudriashov
In reply to this post by stepharo

2016-03-24 20:27 GMT+01:00 stepharo <[hidden email]>:
    • ghost ghostClass "returns actual class of receiver"
                when I read ghostClass I expect getting the class implementing the proxy not the proxied class.
                So I'm confused.

Now I am confused too :))
ghost ghostClass "=> anObjectGhost (or subclass)"

Reply | Threaded
Open this post in threaded view
|

Re: [Ann] New version of Ghost

Denis Kudriashov
I upload new version 2.1 which not mentions word "proxy" anymore.


2016-03-27 21:03 GMT+02:00 Denis Kudriashov <[hidden email]>:

2016-03-24 20:27 GMT+01:00 stepharo <[hidden email]>:
    • ghost ghostClass "returns actual class of receiver"
                when I read ghostClass I expect getting the class implementing the proxy not the proxied class.
                So I'm confused.

Now I am confused too :))
ghost ghostClass "=> anObjectGhost (or subclass)"


Reply | Threaded
Open this post in threaded view
|

Re: [Ann] New version of Ghost

Denis Kudriashov

2016-03-29 16:59 GMT+02:00 Denis Kudriashov <[hidden email]>:
I upload new version 2.1 which not mentions word "proxy" anymore.


2016-03-27 21:03 GMT+02:00 Denis Kudriashov <[hidden email]>:

2016-03-24 20:27 GMT+01:00 stepharo <[hidden email]>:
    • ghost ghostClass "returns actual class of receiver"
                when I read ghostClass I expect getting the class implementing the proxy not the proxied class.
                So I'm confused.

Now I am confused too :))
ghost ghostClass "=> anObjectGhost (or subclass)"



12