- Smart variables
SmartVariables is a term introduced in 1998 referring to a design pattern that merges networking and
distributed object technology with the goal of reducing complexity by transparently sharing information at the workingprogram variable level. [cite conference|first=Brian|last=Foote|coauthors=Joseph Yoder|title=Metadata and Active Object-Models|booktitle=Pattern Languages of Programs Conference|year=1998|url=http://jerry.cs.uiuc.edu/~plop/plop98/final_submissions — Introduced the concept of "smart variables".]SmartVariables style programming interfaces emulate simple "network shared memory." The design emphasis is API simplicity for systems needing to exchange information. Sharing and update behaviors do not need to be explicitly programmed; however "callbacks" can be attached that execute when a "named" object's content changes. SmartVariables attach an email-like "name" to each container or list; when the variable changes value, it automatically propagates change events across the network into other running processes working with that data. Applications do not poll for content changes, as events get processed asynchronously — working program variables simply receive new content. [cite paper | author=Hounshell, Lee | title=Simplifying Web Infrastructure with SmartVariables | publisher=SmartVariables.com | date=March 2006 | format=pdf| url=http://www.smartvariables.com/doc/DistributedProgramming.pdf — Refined and extended the concept, using "smart variables" to simplify
Grid computing and implementweb services , directory, and distributedneural networks .]The concept has some similarities to that of
stored procedures and triggers in database systems, where a change to one item can set off other changes in the database.Programming Basics
This C++ example is from the GPL open-source SmartVariables implementation at SmartVariables.com.Imagine an environment with three networked computers named: Alice, Bob and Charlie.To begin, our program running on “Alice” will function to continuously print out thecontents of a remote container object named “greeting@Charlie.” Here is the code for Alice:
Var greeting; greeting.Name( “greeting@Charlie” ); // attach to and subscribe to the remote object while (1) { cout << “greeting=” << greeting << endl; // note that ‘greeting’ can change values here }
Note that Alice’s display code is in a tight-loop, and there is no code that explicitly connects tomachine “Charlie” to retrieve the “greeting” object or any changes made to it. Next, we run anotherprogram on machine “Bob” that simply changes the value of the remote “greeting@Charlie” objectto be the string “Hello, World!.” Here is the code for Bob:
Var greeting = “Hello, World!”; greeting.Name( “greeting@Charlie” ); // modify all copies, everywhere.
Now, when the above program on machine Bob gets executed, it transparently connects to Charlieand modifies the “greeting” object to have its new value: “Hello, World!.” Because SmartVariablescontainers “know” who have copies of their data, the environment transparently propagates thechange to Alice. SmartVariables propagate themselves into process-level code automatically. Thismeans that the program still looping on Alice will now begin printing its new value of “Hello, World!.”The code on Alice appears to be a “tight loop,” with no opportunity for the object to be modified;however, it does change. Modifications to the “greeting@Charlie” object become automaticallyreflected by Alice’s program output. This behavior is quite amazing to see.
References
External links
* [http://smartvariables.com Open source commercial implementation (beta) in
C++ ] .
Wikimedia Foundation. 2010.