hdolder.com srl  

Software R&D
 

   hdc Home    |    Content    |    Blog    |    Director    |    Contact    |    mail us   

 

M&P H5J More Concepts and Facilities

Posted on March 14, 2013 by Herman Dolder
Last modified on February 19, 2014

In the previous article titled " Concepts and Facilities " we presented a bird's-eye view of the basics of M&P H5J, and in this article we will take a second tour to broaden and deepen some topics as preparation for future more specialized articles.

The M&P platform seeks to maximize the adaptability and the performance of applications by using a modular dataflow architecture based on interchangeable plug-and-play BLOCKS.

Architecture

M&P has an XAML Processor named BXaml that can instantiate BLOCKS types, HTML5 Elements and SVG Elements allowing the declarative composition of applications. BXaml allows to structure sets of BLOCKS instances and to connect them to exchange information via databinding.

The property-to-property databinding provided by BXaml makes the system operate concurrently (asynchronously) in an "dataflow" mode, and this mode facilitates to a great extent the implementation of concurrent and parallel processing.

BLOCKS

Basically a BLOCK type is a TypeScript class that implements an interface (extending a predefined base class) that allows the BLOCK instances to automatically integrate and interoperate with the M&P Runtime (MPRT).

To be able to be instantiated by the BXaml processor the class must be "XAML-friendly" so it is necessary to implement a parameter-less constructor.

The BLOCKS may also be instantiated using Typescript (Javascript) code.

The properties of a BLOCK type that will participate in a databinding must be defined as "Observable Properties" (Op). We will describe the Observable Properties in an specialized article.

To begin to familiarize you with the BLOCK internals we show below the TypeScript code of an "empty" BLOCK (the skeleton of a BLOCK):

export class BPROTO extends blkx.BLOCKBase {
constructor () { //XAML-friendly
super();
/* example
obx.proxyThis(this, "BStart");
*/
this.AddObservableProperties();
this.CreateInnerBlocks();
}

private AddObservableProperties() {
/* example

blkx.CreateObservableProperty(
this, //this BLOCK
"Text", //propname
obx.Box("***"), //inivalue
"string", //XAML typeconverter
this.InputEH //event-handler
);
*/
}

private CreateInnerBlocks() {
var board =
obx.XA.LoadAndStart("BPROTO", this,^this.XamlCode);

}

BStart() { // called from M&P runtime
}

/* example of event handler for OP
private InputEH(value:any, observ):void {
}
*/

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// XAML code - Inner BLOCKS

private MyXamlCode =

"<mpXaml " +
" xmlns:ap='app' " +
" xmlns:mp='mpx' " +
" xmlns:mpx='mpx' " +
" xmlns:blk='blkx' " +
" xmlns:blkx='blkx' " +
" xmlns:bdk='bdkx' " +
" > " +
"<blkx:BBoard id='TopBoard' > " +
// Your code here
" " +
"</blkx:BBoard> " +
"</mpXaml> ";

} // class

In the TypeScript code above we can see

  • it looks very much like a C# code.
  • the example class "BPROTO" inherits from the base class BLOCKBase that contains (hides) the logic for the automatic integration and interoperation of "BPROTO" instances with the M&P Runtime.
  • the constructor is XAML-friendly (parameter-less) and it invokes the functions AddObservableProperties and CreateInnerBlocks.
  • an example of the creation of an ObservableProperty that has an associated event-handler.
  • the instantiation of the "inner" BLOCKS using "in-line" XAML code.
  • the function BStart, which is optional. This function is invoked by the runtime of M&P once completed the processing of instantiations by the BXaml processor. BStart allows you to complete the initialization
    of the BLOCK after the " BLOCKS Tree " has been created and the forward references in XAML have been resolved.


The MPR Startup Protocol

For databindings M&P provides two specialized BLOCKS named BBinding and BReference. To be recognized as databinding BLOCKS by the MPR both BLOCKS define the property

PIBinding: bool = true;

These BLOCKS types are normally instantiated in the XAML code using BXaml Markup Extensions.

Once completed the process of instantiations by the BXaml processor the MPR navigates two times through the resulting BLOCKTree (BT) in a top-down mode invoking the BStart functions of the instances of the BLOCKS in the BT.

In the first navigation the MPR recognizes the databinding BLOCKS instances and invokes their BStart functions

In the second navigation the MPR invokes the BStart functions of the other BLOCKS instances.

We call this facility the "Two-Phase Startup Protocol" of M&P. It provides a pre-established non-ambiguous order for the startup of the applications.

Databinding Dataflow mode

The property-to-property databinding provided by BXaml makes the system operate asynchronously in a "dataflow" mode in which data flows as a consequence of changes of values in the Observable Properties.

The BLOCKS wait and act only when they receive information via their Observable Properties.

See Also

 

 

TBW The BLOCKS World 2015  hdolder.com srl
C30114
2015-06-26