Naming strategies

User supplied strategies for naming SEP nodes and filters

Introduction

The goal is to use a custom supplied strategy to customise node names and filters in the generated SEP. A custom naming strategy can add semantic value to member names that makes supporting the generated SEP easier. The default auto-generated names can be cryptic and confusing due to their similiarity..

Node naming

A developer can customise the node variable names declared within the final SEP by supplying Fluxtion with an instance of the NodeNameProducer arrow-up-rightinterface. This can greatly help debugging and understanding the SEP code as contextually sensitive identifiers can be used within the SEP in place of the default cryptic auto-generated names. The interface is simple, Fluxtion compiler supplies the instance at generation time and the user returns a String name for the node. A null return delegates to the default auto-naming strategy.

public interface NodeNameProducer {
    String mappedNodeName(Object nodeToMap);
}

The Fluxtion maven plugin accepts the fully qualified class name of a NodeNameProducer arrow-up-rightin its configuration section:

<nodeNamingClass>[ NodeNameProducerClass ]</nodeNamingClass>

Filter naming

A developer can customise the filter names and comments declared within the final SEP by supplying Fluxtion with an instance of the FilterDescriptionProducer arrow-up-rightinterface. This can greatly help debugging and understanding the SEP code as contextually sensitive identifiers can be used within the SEP in place of the default cryptic auto-generated names. The interface is simple as shown below. The developer returns a FilterDescription arrow-up-rightwhich also allows comments to be present at filter sites.

public interface FilterDescriptionProducer {
     
    default FilterDescription getFilterDescription(Class<? extends Event> event, int filterId){
        FilterDescription filter = new FilterDescription(event, filterId);
        filter.comment = null;
        filter.variableName = null;
        return filter;
    }
     
    default FilterDescription getFilterDescription(Class<? extends Event> event, String filterString){
        FilterDescription filter = new FilterDescription(event, filterString);
        filter.comment = null;
        filter.variableName = null;
        return filter;
    }
     
}

The Fluxtion maven plugin accepts the fully qualified class name of a FilterDescriptionProducer arrow-up-rightin its configuration section:

Example

The following example implements node and filter naming strategies. The example code is located herearrow-up-right.

Several data handlers are added to the graph in a SEPConfig. Each handler has a filter string, this value will be used to generate the node names in the SEP and the comments on the filters will be customised as well with this strategy:

DataHandler node

SEPConfig

Generated SEP

The generated SEP now has nodes whose names are more human readable due to the naming strategy, see lines 4-6. Filter comments are customised in line with the filter strategy, lines 27, 32 and 37.

The SEP is much easier to map mentally making support a simpler task.

Last updated

Was this helpful?