Xmeta

De Fiatpédia.

xmeta is an object model and abstract layer developped in PHP for Diesel by 12939 Media Architecture. It was designed to be usable independantly of the framework.

The version 2 of xmeta is planned to be released under GPL.

Sommaire

xmeta 1.x

Xmeta-1.2.png

(From the library's javadoc.)

The xmeta object model (_xmeta) has been developped as a structural framework for Diesel 0.3.3. After 4 unsuccessful models were rejected, this model was implemented from it's experimental form (July 2007) into Diesel in September 2007 (Diesel 0.3.2, Dx3.2/xmeta).

Although xmeta.php is the core object model of the Diesel framework (partially since 0.3.2/xmeta, and completely since 0.3.3), it is being designed to be 100% independant of the framework itself.

Major changes are targetted for a version 2.0 (refer to Blue Book) (20090510) ({see xmeta2.php}):

  • reversal of inheritance (xmeta->xdata->xnode);
  • [actual] namespaces making metanodes/childnodes interoperatable and all available throught "(set|let|get)(Node)?" methods (no more "(set|let|get)Meta.*");
  • sweetened $meta array argument syntax for slim source code;
  • no more nodelists; all and only nodes for doing that job ==> reduced code redundancy;
  • important revision of metavariables naming and namespace logic

Changes from 1.1 to 1.2 (20090508):

  • Applied the following rule: -> xdata's data CANNOT BE ANY xmeta OBJECT <-- ; this logic allows objects to be passed by reference in constructors' $meta argument; removes a great load of possible confusion when handling nodes as metavariables;
  • Added clone() method to xmeta, xdata, xnode (first used by Diesel/Data/Table.php), as well as support for 'xmeta:template' metavariable (example of template class: Diesel_Data_Column_Serial);
  • Flushed all outdated 'experimental' x-descendants of xnode

xmeta 2.0

Xmeta 2.0.png

(From the library's javadoc.)

After successfully integrating xmeta 1.0 into Diesel in September 2007, many improvements of the object model (now "abstract layer") were progressively thought. xmeta 2.0, while being backward compatible to version 1.2, implements some inner changes that require a major release.

Reversal of inheritance order

                                                             
               .-------.      .-------.      .-------.            
               | xnode |<- - -| xdata |<- - -| xmeta |            
               `-------'      `-------'      `-------'            
                                                                  
          UML representation of xmeta 2.0 class inheritance       
                                                                  

xmeta 2 reverses the inheritance order of it's predecessor. If "-->" stands for "inherits", from now on: xmeta --> xdata --> xnode. Of course, all version 1 derivatives of xnode should now inherit xmeta instead -- actually the main reason for releasing a new major version!

Surrogation: working with copies instead of references

xmeta nodes deliberately work with copies of nodes instead of references. This decision was first influenced by the Diesel file-based node composition workflow (since Dx3.5's DS5 Workflow), which relies on files returning nodes, but also presents a whole universe of new advantages. In particular, the possibility to overload future xmeta objects, but also the fact that working with copies greatly reduces the risk of reference problems.

The principle is to store and modify properties in a 'surrogate' object instead of relying on the object's own properties. Since copies always reference the same 'surrogate' object, changes are always available to every copy of the original object. The beauty in that trick is that the 'surrogate' object used by an xnode object is simply it's original self.

So now, instead of using $this->nodes, the model's methods use $this->node->nodes. Note that surrogation only applies to properties and does not apply when calling a node's methods.

Surrogation also solves the problem of multiple composition. Only node copies are composed, which allows a node to be composed by different parent nodes while preserving the coherence of the parent-children tree. It's for this purpose that 'parent' and 'index' properties are not transversal (not surrogated).

    .------------.----------------------------------------------.
    | Interface  | Property   | Surrogated | Used internally    |
    |------------+------------+------------+--------------------|
    | xnode      | ->node     |    ---     | $this->node        |
    |            | ->nodes    |    yes     | $this->node->nodes |  
    |            | ->parent   |    no      | $this->parent      |
    |            | ->index    |    no      | $this->index       |
    |            |            |            |                    |
    | xdata      | ->data     |    yes     | $this->node->data  |
    |            |            |            |                    |
    | xmeta      | ->ns       |    yes     | $this->node->ns    |
    `------------^----------------------------------------------'
UML representation of xmeta 2 Object Model

Actual namespaces

The (yet very intuitive) convention of "namespacing" metavariables has proved to be a good guess! In xmeta 2, namespaces are actual, although seen from the "outside" of objects, there is no difference. This will allow enhanced possibilities within the metabolism of xmeta objects, without overwhelming the processes with repeated metavariable lookups. The metabolisms become deeply structural, and less parametric.

This also allows us to treat nodes and metanodes exactly the same way, since metanodes are only nodes in another namespace. This reduces overhead in a significant way: get/set/letMeta*() methods are now simply aliases of their get/set/letNode*() counterpart. Additionally, it is now possible to access both nodes and metanodes using node paths.

The xmeta 2 implementation of class xmeta introduces a new property, node->ns. node->ns is simply a regular xnode object containing namespace nodes, also of class xnode.

By default, xmeta objects have 4 namespaces:

  • xnode: yet another copy of the original object;
  • xdata: a dynamic xmeta node structure that maps a node's data;
  • xmeta: xnode object that contains the object's 'metabolic' parameters;
  • ns: a [reference to|copy of] the node's ->node->ns, making it easy to manipulate it's namespaces using standard get/set/letNode*() methods.

Namespaces can easily be added or automatically created on-the-fly.

Other changes

Also to notice the vanishing of xnodelist & descendants, xcomposition and xaggregation, whose metabolisms are now directly integrated within xnode, reducing overhead even further.

Extended JavaDoc

An important quality that was lacking to xmeta 1.x is rich JavaDoc comments. In contrast, this new brew of xmeta is rather comments than actual code!

EXPERIMENTAL!

This new version is intended to replace xmeta 1.x in Diesel 0.4 (Dx4), whose release is projected in September 2009 (exactly two years after the beginning of integration of Diesel over xmeta 1.0). It is still marked as "experimental". At term, the library (and package as well) will be renamed just "xmeta" and take place of the actual xmeta 1.x.

Links

Récupérée de « http://wiki.fiatlux.tk/wiki/Xmeta »
TOOLBOX
LANGUAGES
page counter