Essentials: Reactive Blocks in a Nutshell

Some things you need to know before you start - from a 1000-feet view.

Reactive simply means to react appropriately to events, keeping an eye on time, and handling events as parallel as possible, but in an ordered way. Such reactive behavior is hard to get right by pure programming only, since most programming languages are really intended to get sequential problems solved. Reactive building blocks, on the other hand, are designed to build reactive applications. The Reactive Blocks SDK is a tool for developing such applications.

Reactive Building Blocks

Reactive building blocks are a new type of software module, especially designed for event-driven applications. A block encapsulates and tightly couples:

  • an activity diagram to represent the data flow graphically by describing concurrent behavior and synchronization,
  • Java code to describe detailed operations,
  • a contract to provide a behavioral contract between the block and its environment by describing the sequence in which the features of the block can be used legally.

Thus, reactive building blocks bring modularization of software to another level, enabling seamless integration between graphics and code: The graphics cover when a certain operation is called, and the operations describe in detail what happens to the data. In addition, reactive builidng blocks enable automatic verification and efficient generation of code.

Find out how to use and create blocks.

Creating Applications

An application consists of a hierarchy of building blocks, which are nested within each other representing different levels of detail. At each level, blocks are connected with each other and various activity nodes by flows. The flows represents data moving within the application, which may be sequential, branched or concurrent. An application is designed graphically with these data flows.

Block Hierarchy

Building an application can be done iteratively with a combination of

  • Bottom-up development: Lego-like, starting with existing blocks.
  • Top-down development: Develope the top most level first and refining later.

As there are many blocks available from libraries, you rarely have to start from scratch. Simply start by dropping existing blocks into your application.

With Reactive Blocks SDK you will make code for the interesting parts of your project, while you will get the tool to generate code for the standard synchronisation (not necessarily trivial) parts of your application. Algorithms are always done best in code.

When you press build, executable Java code is generated. The code is generated from these sources:

  • code you have written
  • code coming with blocks you are importing
  • automatically generated code that implements the graphical specification of the concurrent behaviour in all blocks
  • reactive blocks runtime system

This project will be a complete project that can be executed.

Run-to-Completion Steps

An application is executed step-by-step. A run-to-completion step is always triggered by some event, for example an expiring timer. Once a step is triggered, the application executes all actions which can be executed until it reaches a point where it has to wait for other event. A step is therefore a sub-graph of an activity diagram starting at a trigger and ending where new triggers are needed, including all actions in between. These steps make the execution very efficient, even when many things happen in parallel.

Using the animation you can traverse the behavior of a block step-by-step and find all possible scenarios.

Block Contracts

A block contract is used to describe the contract between the block and its environment ensuring the correct usage of the block.

Data and control is passed between a block and its environment via pins. Pins can represent data flowing from the environment into the block (input pins) or data flowing from the block to the environment (output pins). A block contract describes the sequence in which the pins of a block can be used and thus provide a strong API for the block.

A contract is defined by filling in a table with all legal interactions.

Legal interactions are called transitions. They include:

  • the current state of the block (Source State),
  • the involved input and output pins (Pins),
  • the next state of the block (Target State).

A contract can also be displayed and viewed graphically.

Find out more and learn how to create a contract.