Login  Register

Re: [Ann] New version of Ghost

Posted by Denis Kudriashov on Mar 25, 2016; 1:26pm
URL: https://forum.world.st/Ann-New-version-of-Ghost-tp4886357p4886513.html

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. 
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.

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 


Sorry to bother you but names are really important.

Exactly!!!