Proxy on Hypernodes

Coordinator
Jun 20, 2011 at 3:10 PM

Today we talked about the project and so we decided to have a proxy as remote object returned by the hypernodes.

It would represent our node, and he would work for connections from the client with the server and the synchronization of an element.

Imagining that we in our "language code" we will access to our node with a syntax  like:

var x = "!//$%[@§^§]()$''$$&"; // Somehow with some syntax
x.name = value;
var n = x.name;

we would have a preprocessor that would change the thing in :

x.setValue(name, value); 


var n = x.getValue(name); 
So, "x" is our proxy and i was writing down an object for making it.
var Proxy = function (el, percorso ){
	
		this.element = el;
		this.path = percorso;	
}

Proxy.prototype.setValue =  function(name, value){
	setCallAjax(name,value);
	this.element.setAttribute(name, value);
}

Proxy.prototype.getValue = function(name){
 return	getCallAjax(name);
}

function setCallAjax(name, value){
	
	//TODO Ajax request
	alert("nome = "+name+" valore =  "+value);
}

function getCallAjax(name){
	//TODO Ajax request
	alert('getcall');
	return "valore";
}

My main question is about the getValue()  function.....
We can implement the thing in some different ways depending on synchronization.
SOLUTION 1:
We use it as it is, written up, we call the server object every time for getting synchronized.
SOLUTION 2:
We add a method "Update()" that the user programmer will use if he needs the object synchronized, otherwise use the local object.
SOLUTION 3: 
We make 2 methods getValue and it's up to the programmer to choose the "synchronized" or not.
SOLUTION 4:
We add a boolean attribute "synch" to set, and we make an if to choose the solution.
What's your opinion about it ?

Coordinator
Jun 20, 2011 at 5:41 PM

The var x contains a remote attributes map? What is the benefit to use a proxy object instead of calling static framework functions? I think the most useful implementation would to provide an additional function to attributes map (returned actually by "selectAttributes"), a function "update" that send the updated attributes map to related node on server (inside an hypernode). This permits to simplify the application writing...

Example (as now, after preprocessing):

var attrs = __selectAttributes(theHypernode, thePath);
attrs.attributeA = aValue1;
attrs.attributeB = aValue2;
...
__setAttributes(theHypernode, thePath, attrs);

Example (with update method):

var attrs = __selectAttributes(theHypernode, thePath);
attrs.attributeA = aValue1;
attrs.attributeB = aValue2;
...
attrs.update();


In pratice,  "theHypernode" and "thePath" values are closed into "attrs" object.


The same mechanism would used for nodes...

Example (as now, after preprocessing):

var node = __selectElements(theHypernode, thePath);
var newElem = document.createElement ("div");
newElem.innerHTML = "sample text";
newElem.style.color = "red";
node.appendChild(newElem);
node.setAttribute("attributeA", "value1");
node.setAttribute("attributeB", "value2");
...
__setContent(theHypernode, thePath, node.innerHTML);
__setAttributes(theHypernode, thePath, __selectAttributes(node, ""));

Example (with update method):

var node = __selectElements(theHypernode, thePath);
var newElem = document.createElement ("div");
newElem.innerHTML = "sample text";
newElem.style.color = "red";
node.appendChild(newElem);
node.setAttribute("attributeA", "value1");
node.setAttribute("attributeB", "value2");
...
node.update();

 

In this scenario, methods "getValue" and "setValue" that you have hypotized are unuseful, ther is no need to implement them.

However I remember that in the TODO list there are other tasks yet, we can append this task to it.

Coordinator
Jun 22, 2011 at 8:44 PM

Mine was just an easy implementation from scratch as easy example.

In the talk we had on Monday, the main points were:

1) make explicit for the user programmer the difference between navigation inside the local tree (server or client) or by hypernodes

2) synchronize the object we obtain with a call on an hypernode.

 

So for point 1 we need to have a different syntax on local navigation or cross-web navigation  (and so we need to separate the  methods, for example "selectElements" and "selectRemoteElements", taking away the if checking we use now).

For point 2 we talked about building a proxy, that will have inside the responsibility about remote methods.

The idea of putting a method "getValue" or "setValue" was for creating a corrispondence from our "future syntax", and the calling methods.

I was just thinking that implementing the preprocessing from our probable syntax " x.a = 4;"  to real one made as" x.setValue(a,4)." is a really easy thing.

 

Anyway my main point was a discussion on deciding what to do with the recovering of attributes from hypernodes, strongly synchronized, optionally or not.

Talking only from client side:

1) if we need to be strongly synchronized, we would need that for every change we make an ajax request. So probably a "setValue" or "getValue" may return useful.

2)if we do not need it, or a lazy synchronization, the idea of using a method update and use inside it the "setRemoteAttributes" as it is.

So i was asking opinion about a choose that may be important for the rest.